Interface2017年05月号新画像処理101を読む

1-2 ノシタルジックな雰囲気に変える「セピア・カラー処理」

img_src = cv2.imread("data/Mandrill.png")
#BGR画像を分離してグレイ画像を作成
img_gray = img_src[:,:,0] * 0.33 + img_src[:,:,1] * 0.33 + img_src[:,:,2] * 0.33 

#img_srcと同じ大きさのゼロ配列を作成してimg_dstを構成
img_dst = np.zeros_like(img_src)
#グレイ画像の明度を調整
img_dst [:,:,0] = img_gray * 0.55
img_dst [:,:,1] = img_gray  * 0.8
img_dst [:,:,2] = img_gray

#描画する
cv2.imshow("img_src",img_src)
cv2.imshow("img_dst",img_dst)
cv2.waitKey(0)
cv2.destroyAllWindows()

f:id:bitop:20180115054041p:plain

f:id:bitop:20180115055440p:plain