SUSAN edge detector¶
| Fact | Value |
|---|---|
| Also called | SUSAN edges, USAN edge detector |
| Status | Implemented and tested |
| Family | Edge detection and boundary analysis |
| Engine | Science engine |
| Type | Nonlinear, spatial, edge detection |
| Output | Image |
| Operator shown as | algorithm (simplified) |
| Support radius | 4 plus the minimum length |
| Code | engine/src/pixelnexus_engine/filters/susan.py, susan_edge |
| Operator code | engine/src/pixelnexus_engine/filters/susan.py, susan_edge_representation |
| Packages | NumPy, scikit-image |
Overview¶
The SUSAN edge detector of Smith and Brady finds edges by counting, like the SUSAN corner detector. Around each pixel it places a small disk of 37 pixels and counts how many are about as bright as the center pixel. A flat area fills the disk. On an edge, about half of it is filled. Where the count falls below three quarters of the disk, the pixel lies near an edge, and the smaller the count, the stronger the edge. The detector takes no derivatives. The filter runs in the PixelNexus engine, in PixelNexus's own code.
How it works¶
- Take the luma.
- Around each pixel, add up how similar the 37 pixels of the circle are to it. This is the USAN area n.
- Set the edge response to g - n where n is below g.
- Find the edge direction from the center of gravity of the USAN, or from its longest axis where it is thin.
- Keep the pixels whose response is the largest across the edge.
- Remove edge pieces shorter than the minimum length.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(r_0\): The nucleus, the center pixel
- \(n\): The USAN area
- \(t\): The brightness threshold
- \(g\): The geometric threshold
- \(R\): The edge response
The mask is a circle of 37 pixels around the nucleus r_0. Each pixel counts as similar by a smooth step of the brightness difference, and n, the USAN area, adds them up. USAN stands for univalue segment assimilating nucleus. In a flat area n is 37. On a straight edge it is about half. The edge response R grows as n falls below the geometric threshold g. The paper sets g to three quarters of 37 to reject noise. The edge direction comes from the USAN: the vector from the nucleus to its center of gravity crosses the edge. Where the USAN is a thin line, its longest axis runs along the edge. Non-maximum suppression across the edge then thins it.
The count n is called the USAN area, for univalue segment assimilating nucleus. The similarity of a pixel to the nucleus is a smooth step, exp(-(d / t)^6), where d is their difference in brightness. The paper sets the geometric threshold g to three quarters of the largest area. From its analysis of noise, this rejects noise best. A step edge of any curve still gives an area of at most three quarters on one side, so real edges are not lost.
The edge direction comes from the USAN itself. On a step edge, the USAN lies on one side, and the vector from the nucleus to its center of gravity crosses the edge. When the nucleus sits on a thin band between two regions, the USAN is a thin line along the edge instead. Then the longest axis of the USAN, found from its second moments, gives the direction. The paper uses the thin line case when the area is under the mask diameter, or when the center of gravity is less than 1 pixel from the nucleus.
Kernel or operator¶
The mask is a circle of 37 pixels with a radius of 3.4. The rule is not a weighted sum, so there is no kernel. The Inspector asks the engine for the stages with the current settings.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Output output |
Edges | Edges, Edge response | The thin edges, or the edge response R before suppression, stretched so that R = g is white. |
Brightness threshold brightness |
25 | 1 to 100 levels | How close in brightness a pixel must be to count as similar to the center, the t of the formula. Our choice of 25, as for the SUSAN corners. |
Geometric threshold geometric |
0.75 | 0.1 to 1 | The share of the 37 mask pixels below which a USAN area counts as an edge. The paper uses three quarters for edges. |
Minimum length minLength |
5 | 1 to 50 px | Edge pieces, 8-connected, with fewer pixels than this are removed. 1 keeps all. Our choice of 5, in place of the paper's thinning rules. |
Border mode border |
Reflect 101 (default) | Reflect 101 (default), Reflect, Replicate, Constant (zero), Wrap | How pixels outside the image are filled when the window reaches past the edge. |
Implementation¶
susan_edge in engine/src/pixelnexus_engine/filters/susan.py shares the mask and the similarity with the SUSAN corner detector. It sums the similarity and its moments over the 37 offsets with NumPy. For the longest axis it takes the angle 0.5 atan2(2 Sxy, Sxx - Syy) of the second moments. The paper gives the moments, and this angle is our form of its rule. Non-maximum suppression keeps a pixel when its response is at least that of both neighbors along the normal, rounded to one of four directions. The paper then applies binary thinning rules, which also remove noise points. They are in a report we could not read. In their place, pieces shorter than the minimum length are removed with skimage.morphology.remove_small_objects.
Worked example¶
| Brightness t | Minimum length | Edge pixels | Edges within 2 px of the outline (%) | Outline within 2 px of an edge (%) |
|---|---|---|---|---|
| 15 | 1 | 7185 | 6.2 | 100.0 |
| 15 | 5 | 4917 | 8.2 | 100.0 |
| 25 | 1 | 2805 | 14.5 | 100.0 |
| 25 | 5 | 523 | 73.2 | 100.0 |
| 40 | 1 | 520 | 74.8 | 100.0 |
| 40 | 5 | 373 | 100.0 | 100.0 |
| 60 | 1 | 221 | 99.5 | 63.4 |
| 60 | 5 | 183 | 100.0 | 44.8 |
The image of the figure, with noise of sigma 10 and the geometric threshold of three quarters. The outline is the border of the two shapes before the blur and the noise, 328 pixels long.
The brightness threshold does most of the work against noise. With the noise of sigma 10, a threshold of 25 leaves many stray pieces, and only 14.5 percent of the edge pixels lie near the outline. A minimum length of 5 raises that to 73.2 percent. At a threshold of 40, every edge pixel lies near the outline, and the whole outline is found. At 60, the threshold is close to the contrast of the square, 110 levels before the blur, and less than two thirds of the outline is found.
Complexity¶
- Time: \(O(37 N)\)
- Memory: \(O(N)\)
N is the number of pixels and 37 the size of the mask.
Artifacts and limitations¶
Limitations
- The binary thinning rules of the paper are replaced by a simple minimum length.
- Noise near the brightness threshold leaves short stray pieces.
Artifacts
- Small gaps where the suppression direction is rounded to the wrong one of four.
- Stray short edges in noise when the brightness threshold is low.
Tests¶
The area and the moments must equal a brute-force sum over the mask, to 1e-12. The response must follow the rule of the paper, and a flat area must have the full area and no response. On straight edges at 0, 45, 90 and 135 degrees, the normal must cross the edge. On a one pixel line, the thin line case must give a normal across the line. A step must give a thin line of edges along its whole length, and a noisy disk edges all the way around within 2 pixels of the circle. The minimum length must only remove pixels. The outputs and the representation are checked too.
References¶
- Smith, S. M., and Brady, J. M. SUSAN. A new approach to low level image processing. International Journal of Computer Vision 23(1), 45 to 78, 1997. DOI 10.1023/A:1007963824710.
- Smith, S. M. SUSAN low level image processing, the HTML version of the paper on the author's pages at the University of Oxford. https://users.fmrib.ox.ac.uk/~steve/susan/susan/susan.html