# Region growing algorithm

I have been trying to come up with a region growing algorithm but I'm not sure that I fully understood the region growing segmentation method (for gray-scale images). Please correct me if I'm wrong:

• I start from a seed point chosen by me (brightest value that fits the wanted region ,because the segmentation target is a girl's face).
• From the location of that seed point I compare the adjacent points and if their value is between a given threshold and the seed point value then I add it to the seed point map(matrix).
• I must try all the valid seed points for adjacent neighbors. The result is just plotting the seed point map (matrix).

Almost there:

1. Define a function growRegion(Image, seedX, seedY) that checks the pixel at location seedX, seedY and returns a list of the 4 or 8 pixels surrounding the seed that satisfy the criteria for inclusion. In your case, that is just one threshold so you could easily say, "if the pixel is adjacent to the seed pixel AND it is above the threshold then include it to the list of potential points".

2. Establish a list of points to be checked. For instance seedPoints=[(seedX,seedY)].

3. As long as seedPoints is NOT EMPTY

• Pop a point (someSeedX, someSeedY) from seedPoints (remove it from the list)
• Call the function returnPoints = growRegion(Image, someSeedX, someSeedY)
• For each point in returnPoints mark a white pixel on some Mask image.
• Extend seedPoints with the result of growRegion.

At this point, your Mask image contains all 4-8 connected pixels that satisfy the criteria for inlcudes. seedPoints fills up 4 (or 8) times the rate at which it empties so for large regions this might seem to run slowly.

Hope this helps.

• You are welcome, glad it was helpful. – A_A Oct 28 '16 at 20:11