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

8-5 相対的に暗い領域を抽出する「ブラック・トップハット」

import cv2
import numpy as np

img_src = cv2.imread("data/img_8-5.bmp")

kernel = np.ones((5,5),np.uint8)
img_dst = cv2.morphologyEx(img_src, cv2.MORPH_BLACKHAT, kernel)

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

f:id:bitop:20180322042816p:plain

f:id:bitop:20180322042839p:plain