Connected Components: P S Q S P Q S
Connected Components: P S Q S P Q S
- A set of pixels in which each pixel is connected to all other pixels is called a connected component.
Definition: A pixel p S is said to be connected to q S if there is a path from p
to q consisting entirely of pixels of S .
- A component labeling algorithm finds all connected components in an image and
assigns a unique label to all points in the same component.
Recursive algorithm
- Let is assume that region pixels have the value 0 (black) and that background pixels have the value 255 (white).
(1) Scan the image to find an unlabeled 0 (pixel and assign it a new label L.
(2) Recursively assign a label L to all of its 0 neighbors.
(3) Stop if there are no more unlabeled 0 pixels.
(4) Go to step 1.
-2-
Sequential algorithm
- The sequential algorithm usually requires two passes over the image.
- It works with only two rows of an image at a time.
(1) Scan the image left to right, top to bottom.
(2) If the pixel is 0, then:
(2.1) If only one of its upper and left neighbors has a label, then copy the label.
(2.2) If both have the same label, then copy the label.
(2.3) If both have different labels, then copy the uppers label and enter the
labels in the equivalence table as equivalent labels.
(2.4) Otherwise assign a new label to this pixel and enter this label in the equivalence table.
(3) If there are no more pixels to consider, then go to step 2.
(4) Find the lowest label for each equivalent set in the equivalence table.
(5) Scan the image. Replace each label by the lowest label in its equivalent set.
-3-
Region boundary
- The boundary of a connected component S is the set of pixels of S that are adjacent to background.
- In most applications, one wants to track pixels on the boundary of a region in a
particular order (e.g., clockwise).
(2.1) Set c = s
(2.2) Let b be the west 4-neighbor of s (background pixel)
(3) Consider the eight 8-neighbors of c , starting with b in clockwise order:
n1 , ..., n8
(4) Choose the first ni such that ni S
(4.1) Set c = ni
(4.2) Set b= ni1
(5) Repeat steps 3 and 4 until c = s