# Need help identifying/marking white areas in 2D image

This topic is 1870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'd like to take a grayscale image that contains white blotchy areas and identify the center of these areas. For example, if there's an area that contains pixel values above 240, I want to be able to get the x,y position of the middle of that area. These images explain pretty much what I'm trying to accomplish:

Image containing white areas to be identified:

[attachment=19055:track01.png]

And what I'd like to be able to do:

[attachment=19056:track02.png]

As you can see, I'd like to figure out the center of these areas so I can mark them. Keep in mind that the areas may be irregularly shaped. Also, there would need to be some way of separating the white blobs so they can be considered separate objects. Maybe they are considered separate only if there's a certain amount of black pixels between them or something.

##### Share on other sites

One idea is to convert to a signed distance field. Then find the pixels which are greater in value than its four neighbours ( +/-X. +/-Y)

##### Share on other sites
A distance transform is noisy, it could give arbitrarily many local extrema depending on blob shape.

I'd use a Hough transform:

1) Apply some combination of median filtering, blurring, nonlinear mapping, thresholding to reduce noise, remove useless details, and obtain very white blobs on a very black background.

2) Apply morphological opening with a disk the size of the smallest blobs you want to detect, to make small white blobs disappear. You might want to use a smaller disk and allow some small blobs if blob shape changes too much.

3) After preprocessing, apply a Hough transform. Since you don't care about blob size and shape, you can collapse the 5 dimensions of ellipse detection to 2: bins can correspond to blob centers (one per pixel) and white pixels in the source image can be counted in all bins within a fixed distance (i.e. maximum expected blob radius).
If blobs are larger than expected, you might still get multiple "centers" for one blob.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634066
• Total Posts
3015318
×