技7 輪郭の検出(ハイパス)
7-1 基本的な縦方向の輪郭検出(横方向の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, 0, 0],
[-1, 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()