# Does it matter what edge finding algorithm you use?

I was playing around with an action set that I have that creates edge masks using the Roberts, Robinson, Sobel, Prewitt, and Kirsh algorithms. Because of the differing levels of brightness, I decided to see what happened when I used the "equalize" command on all of them, plus Photoshop's "Find Edges" as well.

I was surprised to find that all of the results equalized were very similar to each other. Thinking about it, even though each algorithm may place more weight on a certain edge than the others, they all must be detecting the same edges and giving them the same rank in importance/brightness.

So is there any reason to use one edge-finding algorithm over another except convenience? It seems as though you could use a combination of curves and equalization to make one algoritm's results mimic the results of another's results.

• Wow man, very cool question! Although, I really do think this should go to some image processing site, or Math... Oct 30, 2014 at 17:15
• By the way, Photoshop uses the "Robinson Compass" edge detection, that is on your list. See this link Oct 30, 2014 at 17:16
• @TFuto - thanks for the link to the paper, too. Do you know if there are there other types of Edge Detection besides Gradient-based and Laplacian based Edge Detection? Nov 1, 2014 at 12:57
• @BShaw: I am not aware anything else, but I can imagine that if you define what you mean by "edge", you can create another approach. E.g. a neural network could be trained to detect certain edge patterns after some input pre-conditioning. Nov 1, 2014 at 18:35
• So... that little slider in Lightroom labeled "Mask" has nothing to do with photography? Nov 9, 2014 at 8:53

There are a quite a few image processing algorithms apart from those commonly used in photo software. Each are designed to enhance certain properties. For example, some common properties are:

• speed
• localisation (good localisation means the detector response is only high near the edge)
• edge size (e.g. only detect large edges)
• edge straightness
• noise (does it pick up say salt and pepper noise as edges)
• corner response (does it recognise corners as edges)
• rotational invariance (edges give the same response regardless of angle)
• illumination invariance (edges give the same response regardless of brightness)

No one edge detector can do it all: For example, illumination invariant detectors will often pick up jpeg artefacts as edges, and true rotationally invariant detectors are often slow.

A visual example from http://www.sci.utah.edu/~cscheid/spr05/imageprocessing/project4/ , shows image and its "Canny" edge detection using a low threshold. We can see the jpeg artifacts clearly.

Edge detectors in photo software are often chosen for speed. This generally means small kernels (neighbourhood size).

Here is an example of a test image with the response of the edge detector, and the response with thresholding and skeletonisation:

Sobel and Prewitt are similar, but only use two kernels (one x and one y - see TFuto's pdf link in the comments to the question for more info). They have worse localisation than the Roberts method. The Roberts method uses eight kernels (N,NE,E,SE,S,SW,W,NW) and so is also more rotationally invariant and seems to handle corners better. The Laplacian of Gaussian (LoG) looks completely different as it uses zero crossings to find the line edges but struggles with corners.

For a normal photograph, many methods that return a simple edge intensity response (e.g. Nobel, Prewitt, Roberts, not LoG) may well look similar. If the image has sharp contrast the differences may become more apparent.

It seems as though you could use a combination of curves and equalization to make one algoritm's results mimic the results of another's results.

If the kernels are quite similar then this is possible. The Sobel and Prewitt methods are mostly indistinguishable even though the Sobel method weights the centre more.

Does it matter what edge finder you use?

• For computational imaging, yes, it can make a big difference for applications such as feature detection and stereo imaging.

• For photography, it depends on which method gives you the best looking results and what you are trying to achieve. For example, one method that gives very sharp contrast may also introduce a lot of noise.

I just remembered that there is another way to create "edge" masks. Picture Window Pro masking module has a "texture masking feature", where you have three choices of method and three window sizes to choose from. Based on the help file, I think this type of edge finding will always produce unique looking results. In PWP's manual's own words

"Max Difference setting computes texture as the largest difference between the central pixel and all the other pixels in its neighborhood. The Average Difference setting computes texture as the largest average difference between the central pixel and all the other pixels in its neighborhood. The Difference from Average setting computes texture as the difference between the central pixel and average of all the other pixels in its neighborhood. These three methods generally produce similar results with Max Difference producing the most pronounced effects and Difference from the Average producing the most subtle effect.

Neighborhood Size

The neighborhood size may be selected as 3x3, 5x5, or 7x7. This selects how large an area around each pixel is considered to be its neighborhood. Smaller values are better at picking up fine detail, but larger values may work better for blurrier images."