Robinson compass¶
| Fact | Value |
|---|---|
| Also called | Robinson |
| Status | Implemented and tested |
| Family | Edge detection and boundary analysis |
| Engine | Browser |
| Type | Nonlinear, spatial, compass convolution |
| Output | Image |
| Operator shown as | fixed-kernel (exact) |
| Support radius | 1 |
| Code | web/src/core/filters/edges/compass.ts, robinsonFilter |
| Operator code | web/src/core/filters/edges/compass.ts, ROBINSON_NORTH |
| Channels | Brightness only, RGB |
Overview¶
The Robinson operator is a compass filter built from the Sobel mask. It turns the mask in eight steps of 45 degrees and keeps the strongest response. Its four axis-aligned masks give exactly the Sobel derivatives, with both signs.
How it works¶
- Correlate the image with each of the eight turned Sobel masks.
- Keep the largest response as the edge strength.
- The direction of that mask is the edge direction.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(R_k\): The mask turned by k steps of 45 degrees
- \(G\): The largest response
The north mask is a Sobel kernel with its bright side at the top. Moving its outer ring by one cell turns it by 45 degrees. The four masks along the axes give plus or minus the Sobel derivatives. The largest of the eight responses is the edge strength, and its mask is the direction.
Opposite masks are negatives of each other, so the eight responses come in four pairs of opposite sign. The largest is always one of the four positive values. The axis-aligned masks give the Sobel G_x and G_y, and the diagonal masks give Sobel-like derivatives along the diagonals.
Kernel or operator¶
The Inspector shows all eight masks, read from the code that turns them. The worked example below lists the eight responses for one window.
Algorithm¶
- Pad the image with the border mode.
- Correlate with each of the eight masks.
- Keep the largest response, or the direction of the mask that gives it.
- Map the result to 8 bits with the output mapping.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Output output |
Largest response | Largest response, Direction of the largest response | The strongest of the eight mask responses, or the direction of that mask. |
Output mapping outputMapping |
Stretch to full range | 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¶
compassFilter in web/src/core/filters/edges/compass.ts turns the Sobel mask with turnMask and keeps the largest of the eight correlations. 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 eight Robinson responses for this window:
| N | NW | W | SW | S | SE | E | NE |
|---|---|---|---|---|---|---|---|
| 0 | -540 | -720 | -540 | 0 | 540 | 720 | 540 |
The east mask is the Sobel K_x kernel, so its response, 720, equals the Sobel Gx. The west mask gives the negative. The filter keeps 720.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(N)\)
N is the number of pixels per channel. Eight 3x3 correlations per pixel.
Artifacts and limitations¶
Limitations
- The direction has only eight values.
- Sensitive to noise.
Artifacts
- Thick edges and a coarse direction map.
Tests¶
The reference turns the mask the same way. Before it is used, the script checks that the south mask equals scipy.ndimage.sobel along y. The test covers both outputs for all five border modes.
References¶
- Robinson, G. S. Edge detection by compass gradient masks. Computer Graphics and Image Processing 6(5), 492 to 501, 1977. DOI 10.1016/S0146-664X(77)80024-5.
- Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Section 10.2.