An edge pixel in an image is a pixel that is part of an edge. An edge is a region in the image where values change quickly across some line drawn on the region. In other words, an edge is a region that has a high derivative along some line that goes through the region.
This app uses the Canny edge detection algorithm to detect edge pixels in an image. Here’s the steps of the algorithm:
- Get the gradient of the image
- Smooth the image with a gaussian kernel
- Get the gradient of the smoothed image (by using a gradient obtaining kernel)
- We smoothed first becauset the derivative of a noisy function is very noisy
- Thin fat edges
- for each pixel in the gradient image, see if it is a local maximum along the gradient direction in that pixel, if so, keep it, otherwise discard it
- “Linking and thresholding”
- to the thinned gradient image, apply a high threshold to obtain a gradient image that only contains strong pixels
- to the thinned gradient image, apply a low threshold to obtain a gradient image that contains even weak pixels
- go through the low threshold gradient image, for weak pixels that have at least one neighbor in the high threshold image, pick that weak pixel as an edge
- in other words, if a weak pixel has at least one strong pixel as a neighbor, we will consider the weak pixel as a “continuation” of an edge
Since convolution () is a linear operator, then must be true, therefore we can take the derivative of the gaussian kernel first (its smaller, less work), and then convolve that resulting filter with the image.
Use the app below or click here for the full screen version.