Image.canny#
- Image.canny(sigma: int | float = 1, th0: float | int | None = None, th1: float | int | None = None) Any[source]#
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:
Imageinstance
Computes an edge image obtained using the Canny edge detector algorithm. Hysteresis filtering is applied to the gradient image: edge pixels >
th1are connected to adjacent pixels >th0, those belowth0are 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
th1is 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.
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 11.5.1.3.