

Connected components extraction
Code
A small library (written in C)
allowing 2D or 3D connected components extraction, including:
- hysteresis thresholding (see the page on edge detection)
- specification of the minimal size of the connected components to
be retained
- choice of the connectivity (among 4, 8, 6, 10, 18, 26)
- specification of the maximal number of connected components to
be retained (by specifying 1, only the largest connected component is retained)
Examples obtained with the code
| Original binary image |
 |
- Labeling the connected components: a different grey level value
(from 1 to the number of connected components) is given to each
component. Here, there are 36 connected components.
| Counting the connected components |
|
%test-connexe-pnm ironbin.ppm ironcc.ppm -v
|
 |
- Filtering the connected components by size: only the connected
components with a size larger than the minimal size are retained .
Here, there are 16 connected components of size larger or equal
to 10.
| Selecting the connected components by size |
|
%test-connexe-pnm ironbin.ppm ironccsize=10.ppm -ms 10 -v
|
 |
- Ordering the connected components by size: only the n
largest connected are kept. Labels are given in the order of
decreasing sizes (1 is the largest connected component, etc).
| Ordering the connected components by size |
|
%test-connexe-pnm ironbin.ppm ironccmax=n.ppm -ms n -v
|
 |
 |
| n=10 |
n=1 |
Download area
Available through
anonymous FTP
for non-commercial uses only.
Author and contact
Gregoire Malandain