Page 1 of 1

Remove clusters of pixels

Posted: 2012-05-30T14:47:32-07:00
by waigani
http://stackoverflow.com/questions/1082 ... -of-pixels

Is there any method that would detect the clusters of pixels outlined in the question above?

Re: Remove clusters of pixels

Posted: 2012-05-30T15:28:20-07:00
by fmw42
I don't see any pixel clusters indicated. The second image is totally black in Safari.

Re: Remove clusters of pixels

Posted: 2012-05-30T19:27:36-07:00
by anthony
I see them fine in Firefox.

I would start by using morphology to generate a mask surrounding all the pixel groups. That is 'close' (open as your image is black on white) the gaps between 'near' pixels. That should simplify the image.

Once that is done you can find 'isolated' groups by eroding (dialate due to neagtivity) those cluster masks. What is left can be used as seed for a conditional dialation (conditional erosion) using the previous un-eroded image - without the 'isolated' clusters.

You now have a mask for the un-isolated clusters that can be used with the original image.

Basically -- simplify -- locate desired quality -- and restore (re-construct) those areas.

PS: it is probably easier to first negate the image, so you use the right morphology terminology for your processing.

See Morphology
http://www.imagemagick.org/Usage/morphology/#basics

Re: Remove clusters of pixels

Posted: 2012-06-07T01:32:28-07:00
by VanGog
It would be good to have some function for this purpose.

It should be simple to select white areas, contract it a little bit to exclude the little white areas (we want to get only big white area). And then the new function needed to extend the "selection" (in terms of Photoshop; fill - in terms of IM) inside. So you would have mask with one big area white. The selection would be extended but not outwards, but inwards. This would remove the isolated areas.

Re: Remove clusters of pixels

Posted: 2012-06-07T19:43:17-07:00
by anthony
VanGog wrote:It would be good to have some function for this purpose.

It should be simple to select white areas, contract it a little bit to exclude the little white areas (we want to get only big white area). And then the new function needed to extend the "selection" (in terms of Photoshop; fill - in terms of IM) inside. So you would have mask with one big area white. The selection would be extended but not outwards, but inwards. This would remove the isolated areas.
The problem is unless you are 'smoothing' which uses the same kernel set, it is very image dependant.

In your case you want a small one for generating a cluster mask. and a different one to remove isolated clusters.