Algorithm: 4-neighborhood and 8-neighborhood region identification.
1. First pass: Search the entire image R row by row and assign a non-zero value v to each non-zero pixel R(i,j). The value v is chosen according to the labels of the pixels neighbors where the property neighboring is defined by Fig 3 (‘neighbors’ outside the image R are not considered),
• If all the neighbors are background pixels (with pixel value zero), R(i,j) is assigned a new (and as yet) unused label.
• If there is just one neighboring pixel with a non-zero label, assign this label to the pixel R(i,j).
• If there is more than one non-zero pixel among the neighbors, assign the label of any one to the labeled pixel. If the labels of any of the neighbors differ (label collision) store the label pair as being equivalent. Equivalence pairs are stored in a separate data structure- an equivalence table.
2. Second pass: All of the region-pixels were labeled during the first pass but some regions have pixels with different labels (due to label collisions). The whole image is scanned again, and pixels re-labeled using the equivalence table information (for example, with the lowest value in an equivalence class).
• Label collision is a very common occurrence -- examples of image shapes experiencing this are U-shaped objects, mirrored E (∃) objects, etc.
• The equivalence table is a list of all label pairs present in an image; all equivalent labels are replaced by a unique label in the second step.
• The algorithm is basically the same in 4-connectivity and 8-connectivity, the only difference being in the neighborhood mask shape.
• It is useful to assign the region labels incrementally to permit the regions to be counted easily in second pass. Example for partial result is in Fig 3.
• The region counting task is closely related to the region identification problem.
• Object counting can be an intermediate result of region identification. If it is only to count regions with no need to identify them, a one-pass algorithm is sufficient.
Fig 4: Object identification in 8-connectivity. (a), (b), (c) Algorithm steps. Equivalence table after step (b): 2-5,5-6,2-4
Algorithm: Region identification in run-length encoded data
1. First pass: Use a new label for each continuous run in the first image row that is not part of the background.
2. For the second and subsequent rows, compare positions of runs. If a run in a row does not neighbor (in the 4- or 8- sense) any run in the previous row, assign its label to the new run. If the new run neighbors more than one run
in the previous row, a label collision has occurred. Collision information is stored in an equivalence table, and the new run is labeled using the label of any one of its neighbors.
3. Second pass: Search the image row by row and re-label the image
according to the equivalence table information.
If the segmented image is represented by a quad tree data structure, the following algorithm may be applied.
Comments
Post a Comment