machinevisiontoolbox.Image.canny
- Image.canny(sigma=1, th0=None, th1=None)
Canny edge detection
- Parameters:
sigma (float, optional) – standard deviation for Gaussian kernel smoothing, defaults to 1
th0 (float) – lower threshold
th1 (float) – upper threshold
- Returns:
edge image
- Return type:
Image
instance
Computes an edge image obtained using the Canny edge detector algorithm. Hysteresis filtering is applied to the gradient image: edge pixels >
th1
are connected to adjacent pixels >th0
, those belowth0
are set to zero.Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Read('monalisa.png') >>> edges = img.canny()
- Note:
Produces a zero image with single pixel wide edges having non-zero values.
Larger values correspond to stronger edges.
If
th1
is zero then no hysteresis filtering is performed.A color image is automatically converted to greyscale first.
- References:
“A Computational Approach To Edge Detection”, J. Canny, IEEE Trans. Pattern Analysis and Machine Intelligence, 8(6):679–698, 1986.
Robotics, Vision & Control for Python, Section 11.5.1.3, P. Corke, Springer 2023.