Attribute opening¶
| Fact | Value |
|---|---|
| Also called | Diameter opening, Connected attribute opening |
| Status | Implemented and tested |
| Family | Morphological filters |
| Engine | Science engine |
| Type | Nonlinear, morphological, connected attribute filter |
| Output | Image |
| Operator shown as | algorithm (exact) |
| Support radius | global |
| Code | engine/src/pixelnexus_engine/filters/tree_morphology.py, attribute_opening |
| Operator code | engine/src/pixelnexus_engine/filters/tree_morphology.py, attribute_stages |
| Packages | scikit-image |
| Channels | RGB, Brightness only, Color only |
Overview¶
An attribute opening removes bright components that fail a size test, after Breen and Jones, and keeps every other structure exactly. Here the test is the area or the diameter, the longer side of the bounding box. A diameter opening removes compact blobs but keeps long thin lines, which an area opening of a similar size would remove. The filter runs in the PixelNexus engine, with scikit-image.
How it works¶
- Build the tree of the bright components of all threshold levels.
- Measure each component's diameter or area.
- Remove the components below the threshold.
- Give each pixel the level of the nearest component that is kept.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(\Lambda\): The attribute test
- \(C\): A bright connected component of a threshold level
- \(t\): A threshold level
Threshold the image at every level t. Each bright component C of a level passes when its attribute meets the test Lambda, here an area or a diameter of at least the threshold. A pixel keeps the highest level at which it still lies in a passing component. Breen and Jones showed that an increasing attribute, one that only grows as a component grows, gives an opening. Area and diameter both grow with the component. scikit-image builds a max-tree of the components, after Salembier, Oliveras and Garrido, and checks each node once.
Breen and Jones generalized the area opening. Any attribute that only grows as a component grows gives an opening, when components below a threshold are removed. The area is one such attribute. The diameter, here the longer side of the bounding box, is another. It measures extent, not mass, so a line of 70 by 1 pixels has a diameter of 70 and an area of only 70.
Kernel or operator¶
There is no fixed kernel. The Inspector asks the engine for the stages with the current settings.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Attribute attribute |
Diameter | Diameter, Area | The diameter is the longer side of the bounding box of a component, as scikit-image measures it. The area is its number of pixels. |
Threshold threshold |
8 | 1 to 10000 | Components whose attribute is below this are removed, in pixels across for the diameter or pixels for the area. scikit-image uses 8 for the diameter. |
Neighbors connectivity |
8 (sides and corners) | 8 (sides and corners), 4 (sides only) | Which neighbors join a component. scikit-image uses 4, its connectivity 1. 8 is our choice, as for connected-component labeling. |
Channels channelScope |
RGB | RGB, Brightness only, Color only | Which part of the color image the filter changes. |
Implementation¶
attribute_opening in engine/src/pixelnexus_engine/filters/tree_morphology.py rounds each plane of the channel scope to 8 bits and calls skimage.morphology.diameter_opening or area_opening.
Worked example¶
| Attribute | Threshold | Specks left (1 / 2 / 3 / 4 px) | Dark pits left | Line kept |
|---|---|---|---|---|
| diameter | 4 | 0 / 0 / 0 / 10 | 22 | yes |
| diameter | 8 | 0 / 0 / 0 / 0 | 22 | yes |
| diameter | 32 | 0 / 0 / 0 / 0 | 22 | yes |
| area | 4 | 0 / 10 / 10 / 10 | 22 | yes |
| area | 8 | 0 / 0 / 10 / 10 | 22 | yes |
| area | 32 | 0 / 0 / 0 / 0 | 22 | yes |
The image of the figure, with 8 neighbors. There are 10 bright specks of each side from 1 to 4 pixels, so of 1, 4, 9 and 16 pixels. A speck is left when its corner pixel stays above 150. The dark pits are 3 x 3, and are counted by their pixels at or below 30. The line kept column says whether the horizontal line, 1 pixel thick and 70 long, stays above 150 along its whole length.
A diameter of 4 removes the specks of 1 to 3 pixels across and keeps the 4 x 4 ones, since their diameter is 4. A diameter of 8 removes all specks. The lines keep their diameters of 70 and 80, so they stay even at 32. By area, the line of 70 pixels would go at 256, as the area opening shows.
Complexity¶
- Time: \(O(N log N)\)
- Memory: \(O(N)\)
N is the number of pixels, for building the tree.
Artifacts and limitations¶
Limitations
- The diameter comes from the bounding box, so a diagonal line counts as wide in both directions.
- Noise can join small structures to large ones, which then survive.
Artifacts
- Flat plateaus where peaks were cut.
Tests¶
The diameter opening must equal scikit-image's own call and keep a line of 30 by 1 pixels that an area of 31 removes. The representation must have its three stages.
References¶
- Breen, E. J., and Jones, R. Attribute openings, thinnings, and granulometries. Computer Vision and Image Understanding 64(3), 377 to 389, 1996. DOI 10.1006/cviu.1996.0066.
- Salembier, P., Oliveras, A., and Garrido, L. Antiextensive connected operators for image and sequence processing. IEEE Transactions on Image Processing 7(4), 555 to 570, 1998. DOI 10.1109/83.663500.
- scikit-image documentation, skimage.morphology.diameter_opening and area_opening.