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

7-2 基本的な横方向の輪郭検出(縦方向の1次微分

import cv2
import numpy as np

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

# カーネル
kernel = np.array([[0, -1, 0],
                    [0, 1, 0],
                    [0, 0, 0]])
img_dst = cv2.filter2D(gray, -1, kernel)

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

f:id:bitop:20180214060504p:plain

f:id:bitop:20180311081100p:plain