Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you'll probably facepalm ....

>>> 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 apertureSize 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

you'll probably facepalm ....

>>> 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 apertureSize (or all following params) by 'key=value', '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

you'll probably facepalm ....

>>> 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 apertureSize (or all following params) 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

you'll probably facepalm ....it's only a python 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

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