AKTIVE

Documentation
Login

Documentation

Project ↗ Documentation ↗ Tutorials ↗ How To's ↗ Explanations ↗ References
Entry ↗ Sections ↘ Permuted Sections ↘ Names ↘ Permuted Names ↘ Strict ↘ Implementations ↘

Documentation -- Reference Pages -- accessor morphology

Table Of Contents

Operators

Operators


aktive op connected-components get

Syntax: aktive op connected-components get src [→ definition]

Returns a dictionary describing all the connected components of the single-band input.

The input is expected to be binary. If not, all values > 0 are treated as the foreground searched for components.

The components are identified by integer numbers.

The data of each component is a dictionary providing the component's area, bounding box, centroid location, and parts list. Note that the centroid is not the same as the center of the bounding box.

The area value is an unsigned integer number indicating the number of pixels covered by the component.

The bounding box value is a 4-element list holding the x- and y-coordinates of the upper-left and lower-right points of the bounding box, in this order. In other words the x- and y- min coordinates followed by the x- and y- max coordinates.

The centroid value is a 2-element list holding the x- and y-coordinates of the point, in this order.

The parts value is an unordered list of the row ranges the component consists of. A single range value is a 3-element list holding the y-coordinate of the range, followed by the min and max x-coordinates the range covers.

See "aktive op connected-components labeled" for a transformer command built on top of this.

Note that this operation can also be used to determine the perimeters of the connected components. Instead of using the image with the regions directly as the operation's input pre-process it with "aktive op morph gradient internal" (radius 1) to highlight the region boundaries and feed that result in. The boundary components are the desired perimeters of the original regions. See the second example. Beware, there is currently a mismatch here. The morphological gradient is based on a 8-neighbourhood. Connected components on the other hand uses a 4-neighourhood.

Input Description
src Source image

Examples

@1
 
aktive op connected-components get @1
 
times 8@1
geometry(0 0 264 88 1)
cc.pretty 1 {
    area 8
    box {0 0 5 2}
    centroid {3.125 1.625}
    parts {
        {0 5 5} {1 5 5} {2 0 5}
    }
}
2 {
    area 15
    box {1 1 9 6}
    centroid {5.266666666666667 3.4}
    parts {
        {1 8 9} {2 8 9} {3 7 8} {4 1 7} {5 1 1}
        {6 1 1}
    }
}
3 {
    area 8
    box {12 1 14 3}
    centroid {13.0 2.0}
    parts {
        {1 12 14} {2 12 12} {2 14 14} {3 12 14}
    }
}
4 {
    area 18
    box {16 1 20 6}
    centroid {18.0 3.5}
    parts {
        {1 16 20} {2 16 16} {2 20 20} {3 16 16}
        {3 20 20} {4 16 16} {4 20 20} {5 16 16}
        {5 20 20} {6 16 20}
    }
}
5 {
    area 45
    box {22 1 32 7}
    centroid {27.0 3.422222222222222}
    parts {
        {1 24 30} {2 23 31} {3 22 32} {4 22 24}
        {4 30 32} {5 22 23} {5 31 32} {6 23 24}
        {6 30 31} {7 24 25} {7 29 30}
    }
}
6 {
    area 15
    box {1 4 9 9}
    centroid {4.733333333333333 6.6}
    parts {
        {4 9 9} {5 9 9} {6 3 9} {7 2 3} {8 1 2}
        {9 1 2}
    }
}
7 {
    area 18
    box {22 5 32 10}
    centroid {27.0 8.61111111111111}
    parts {
        {5 27 27} {6 27 27} {7 27 27} {8 27 27}
        {9 22 32} {10 26 28}
    }
}
8 {
    area 8
    box {5 8 10 10}
    centroid {6.875 8.375}
    parts {
        {8 5 10} {9 5 5} {10 5 5}
    }
}
9 {
    area 20
    box {12 8 19 10}
    centroid {15.5 8.8}
    parts {
        {8 12 19} {9 12 19} {10 12 13} {10 18 19}
    }
}

@1
 
@2
 
aktive op connected-components get @2
 
times 8@1
geometry(0 0 200 104 1)
times 8@2
geometry(0 0 200 104 1)
cc.pretty 1 {
    area 18
    box {1 1 4 7}
    centroid {2.5 4.0}
    parts {
        {1 1 4} {2 1 1} {2 4 4} {3 1 1} {3 4 4}
        {4 1 1} {4 4 4} {5 1 1} {5 4 4} {6 1 1}
        {6 4 4} {7 1 4}
    }
}
2 {
    area 14
    box {9 1 22 1}
    centroid {15.5 1.0}
    parts {
        {1 9 22}
    }
}
3 {
    area 28
    box {7 3 15 9}
    centroid {11.0 6.0}
    parts {
        {3 7 15} {4 7 7} {4 15 15} {5 7 7} {5 15 15}
        {6 7 7} {6 15 15} {7 7 7} {7 15 15} {8 7 7}
        {8 15 15} {9 7 15}
    }
}
4 {
    area 12
    box {9 5 13 7}
    centroid {11.0 6.0}
    parts {
        {5 9 13} {6 9 9} {6 13 13} {7 9 13}
    }
}
5 {
    area 24
    box {13 10 23 12}
    centroid {18.208333333333332 11.208333333333334}
    parts {
        {10 18 23} {11 13 18} {11 23 23} {12 13 23}
    }
}