Frei-Chen¶
| Fact | Value |
|---|---|
| Also called | Frei-Chen edge detector |
| Status | Implemented and tested |
| Family | Edge detection and boundary analysis |
| Engine | Browser |
| Type | Nonlinear, spatial, subspace projection |
| Output | Image |
| Operator shown as | fixed-kernel (exact) |
| Support radius | 1 |
| Code | web/src/core/filters/edges/compass.ts, freiChenFilter |
| Operator code | web/src/core/filters/edges/compass.ts, FREI_CHEN |
| Channels | Brightness only, RGB |
Overview¶
The Frei-Chen operator splits each 3x3 window into nine standard patterns: four edges, four lines and the mean. It reports how much of the window, as a share, looks like an edge or like a line. Because it is a share, a faint edge and a strong edge of the same shape give the same result.
How it works¶
- Correlate the window with the nine orthonormal masks.
- Add up the squared responses of the edge masks, or of the line masks.
- Divide by the sum of all nine and take the square root.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(F_k\): The nine orthonormal masks
- \(S\): The edge or the line subspace
The nine Frei-Chen masks are an orthonormal basis of 3x3 windows: four span edges, four span lines and one is the mean. The squared projections add up to the energy of the window. The ratio of the edge or line energy to the total is the squared cosine of the angle between the window and that subspace. The output is 255 times the cosine, so a pure edge or line gives 255.
The nine masks are an orthonormal basis of 3x3 windows, so the squared responses add up to the energy of the window. The ratio of the edge energy to the total is the squared cosine of the angle between the window, seen as a 9-dimensional vector, and the edge subspace. The output is 255 times that cosine. In flat areas the energy is tiny, so small noise patterns can still give a large share.
Kernel or operator¶
The Inspector shows the nine masks, read from the code. The worked example below projects one window.
Algorithm¶
- Pad the image with the border mode.
- Correlate with the nine masks.
- Add the squared responses of the chosen subspace and of all nine.
- Write 255 times the square root of their ratio.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Output output |
Edge subspace | Edge subspace, Line subspace | Which part of the window to measure. |
Output mapping outputMapping |
Clip to 0 to 255 | Absolute value, Offset by 128, Stretch to full range, Clip to 0 to 255 | How signed results, such as gradients, become 8-bit pixel values. |
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. |
Channels channelScope |
Brightness only | RGB, Brightness only | Which part of the color image the filter changes. |
Implementation¶
freiChenFilter in web/src/core/filters/edges/compass.ts correlates with the nine masks and forms the ratio. A window with no energy gives 0. The filter runs in the browser engine, in Web Workers, through the shared filter framework in web/src/core/filters/run.ts, which handles the border mode, the channel scope, alpha and the output mapping. By default it works on luma and gives a gray result.
Worked example¶
The window is a vertical step. The filter gives 160.7 for the edge output, 255 times the cosine of the angle to the edge subspace, and 92.8 for the line output. The mean mask holds the rest of the energy, 47 percent, because the window is bright on average. Of the energy outside the mean, the edge subspace holds 75 percent.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(N)\)
N is the number of pixels per channel. Nine 3x3 correlations per pixel.
Artifacts and limitations¶
Limitations
- Flat areas with tiny noise can look like perfect edges, because only the shape counts.
- The output mapping must not stretch it, or the noise grows.
Artifacts
- Bright noise in flat areas, where the window energy is small.
Tests¶
The reference projects onto the same nine masks. Before it is used, the script checks that the masks are orthonormal. The test covers both outputs for all five border modes.
References¶
- Frei, W. and Chen, C.-C. Fast boundary detection, a generalization and a new algorithm. IEEE Transactions on Computers C-26(10), 988 to 998, 1977. DOI 10.1109/TC.1977.1674733.