I have recently come across a problem that I cannot seem to solve. I have a processed image that contains a number of pixels spread out across the entire image in small ‘local’ groups. I would like to find the ‘centre’ as it were of each group and place a single pixel in the output image as a representative of each group. The groupings can either be a closely knit group with no pixel zero spacing between them or a smaller spread out group with only a few (less than 4~5 pixels) between them. My first thought was to use something along the lines of morphological erosion but this doesn’t account for the case of slightly more spread out groups of pixels. I would just like to know if someone can point me in the right direction. The following is an example of what I would like to do:

The left hand side image shows the input (the big black dot represents a group of pixels with no zeroes between them) and the right hand side image is an example of the type of output or processed image I would like to have. Finally I am using MATLAB and it can be assumed that the input image is a binary image (either with black being 1 or 0 either way the logic should be the same).
Thanks so much for your help!
EDIT: Thanks everyone for their input – I will be trying out the different solutions over the next day or so and I will try to reply to everyone whence I’m done. Thank you all so much for your insightful inputs – it is greatly appreciated.
I’d recommend an approach involving morphological closing followed by connected component analysis. Note that I’ve inverted the problem so the “good dots” are high-valued and the “bad background” is black. This fits more closely with the expected definition of the morphological operations.
The results look like this:
Seems to me to be what you’re looking for!