Region Growing Segmentation
Given a 2D grayscale image, a list of seed positions, and a threshold T, perform region growing segmentation.
Algorithm:
- Each seed starts a new region with a unique label (1, 2, 3, ...)
- For each region, maintain a growing queue (BFS)
- A neighboring pixel (4-connected) is added to the region if:
- It is not yet labeled
- (strictly less than)
- Update the region mean as pixels are added
- Pixels not claimed by any region remain 0
Return the labeled image.
Example
image = [[10, 12, 50], [11, 13, 55], [52, 54, 53]] seeds = [(0, 0), (0, 2)] T = 5
[[1, 1, 2], [1, 1, 0], [0, 0, 0]]
- The algorithm starts with two seeds at positions (0, 0) and (0, 2) with initial labels 1 and 2, respectively. The region mean for label 1 is 10 and for label 2 is 50.
- The neighboring pixels of the seed (0, 0) are checked: the pixel to the right has an intensity of 12, which satisfies , so it's added to region 1 and the region mean is updated to .
- The pixel below the seed (0, 0) has an intensity of 11, which satisfies , so it's also added to region 1, and the region mean is updated to .
- The algorithm continues, but no other pixels satisfy the condition for either region, especially since the threshold is not met for the pixels near the seed (0, 2) to expand into the lower-right part of the image, resulting in the given output.
Constraints
- image is a 2D list of numeric intensities
- seeds is a list of (row, col) tuples
- T is a positive threshold
- Use 4-connectivity
- Region mean updates as pixels are added
- Return 2D labeled list