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

8-2 明るいノイズ(白領域)を収縮させて消せる「エロージョン」

import cv2
import numpy as np

img_src = cv2.imread("data/img_8-2.bmp")
gray = cv2.cvtColor(img_src, cv2.COLOR_RGB2GRAY)

kernel = np.ones((5,5),np.uint8)
img_dst = cv2.erode(img_src,kernel,iterations = 1)

cv2.imshow("img_src",img_src)
cv2.imshow("img_dst",img_dst)
cv2.waitKey(0)
cv2.destroyAllWindows()

f:id:bitop:20180321110253p:plain

f:id:bitop:20180321110326p:plain