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:

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 below th0 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: