Ask Your Question
0

canny apertureSize parameter doesn't work

asked 2015-10-23 05:27:30 -0600

boaz001 gravatar image

The apertureSize parameter as described by the canny documentation does not give any difference in the detected edges.

Here is my code:

thresh1 = 100
thresh2 = 200
aperture1 = 3
aperture2 = 7
img = cv2.imread("lena.png", 0)
edges1 = cv2.Canny(img, thresh1, thresh2, aperture1)
edges2 = cv2.Canny(img, thresh1, thresh2, aperture2)
cv2.imshow("result aperture 3", edges1)
cv2.imshow("result aperture 7", edges2)
cv2.waitKey()

Why are both result images identical?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-10-23 05:38:47 -0600

berak gravatar image

updated 2015-10-23 05:45:48 -0600

it's only a python (syntax) problem, nothing to do with Canny :

>>> help(cv2.Canny)
Help on built-in function Canny:

Canny(...)
    Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) -> edges

since you try to skip the 'edges' argument, you have to reference all following args by 'key=value', so:

import cv2
import numpy as np

thresh1 = 100
thresh2 = 200
aperture1 = 3
aperture2 = 7
img = cv2.imread("im/lena.png", 0)
edges1 = cv2.Canny(img, thresh1, thresh2, apertureSize=aperture1) 
edges2 = cv2.Canny(img, thresh1, thresh2, apertureSize=aperture2)
cv2.imshow("result aperture 3", edges1)
cv2.imshow("result aperture 7", edges2)
cv2.waitKey()

image description

edit flag offensive delete link more

Comments

as i understand from the source aperture_size have the values only -1,3,5,7

sturkmen gravatar imagesturkmen ( 2015-10-23 06:00:55 -0600 )edit
1

thank you @berak. Python beginner here.., thanks for explaining

boaz001 gravatar imageboaz001 ( 2015-10-23 07:44:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-23 05:27:30 -0600

Seen: 523 times

Last updated: Oct 23 '15