opencv チュートリアル チャレンジ7 Canny法によるエッジ検

Canny法によるエッジ検出 — OpenCV-Python Tutorials 1 documentation

cv2.Canny

void cv::Canny   (
    InputArray  image,
    OutputArray     edges,
    double  threshold1,
    double  threshold2,
    int     apertureSize = 3,
    bool    L2gradient = false 
)

image   8-bit input image.
edges   output edge map; single channels 8-bit image, which has the same size as image .
threshold1  first threshold for the hysteresis procedure.
threshold2  second threshold for the hysteresis procedure.
apertureSize    aperture size for the Sobel operator.
L2gradient  a flag, indicating whether a more accurate ....

やってみる

元画像 f:id:pongsuke:20170519145649j:plain

edges = cv2.Canny(img_gray, 50, 150, apertureSize=3)

f:id:pongsuke:20170519145721p:plain

edges = cv2.Canny(img_gray, 20, 100, apertureSize=3)

f:id:pongsuke:20170519150904p:plain

edges = cv2.Canny(img_gray, 50, 150, apertureSize=7)

f:id:pongsuke:20170519150912p:plain