canny(image, sigma=1.0, low_threshold=None, high_threshold=None, mask=None, use_quantiles=False)
The steps of the algorithm are as follows:
Smooth the image using a Gaussian with sigma
width.
Apply the horizontal and vertical Sobel operators to get the gradients within the image. The edge strength is the norm of the gradient.
Thin potential edges to 1-pixel wide curves. First, find the normal to the edge at each point. This is done by looking at the signs and the relative magnitude of the X-Sobel and Y-Sobel to sort the points into 4 categories: horizontal, vertical, diagonal and antidiagonal. Then look in the normal and reverse directions to see if the values in either of those directions are greater than the point in question. Use interpolation to get a mix of points instead of picking the one that's the closest to the normal.
Perform a hysteresis thresholding: first label all points above the high threshold as edges. Then recursively label any point above the low threshold that is 8-connected to a labeled point as an edge.
Grayscale input image to detect edges on; can be of any dtype.
Standard deviation of the Gaussian filter.
Lower bound for hysteresis thresholding (linking edges). If None, low_threshold is set to 10% of dtype's max.
Upper bound for hysteresis thresholding (linking edges). If None, high_threshold is set to 20% of dtype's max.
Mask to limit the application of Canny to a certain area.
If True then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If True then the thresholds must be in the range [0, 1].
The binary edge map.
Edge filter an image using the Canny algorithm.
>>> from skimage import featureSee :
... # Generate noisy image of a square
... im = np.zeros((256, 256))
... im[64:-64, 64:-64] = 1
... im += 0.2 * np.random.rand(*im.shape)
... # First trial with the Canny filter, with the default smoothing
... edges1 = feature.canny(im)
... # Increase the smoothing for better results
... edges2 = feature.canny(im, sigma=3)
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.feature._canny.canny
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them