Remove clusters of pixels

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
waigani
Posts: 2
Joined: 2012-05-12T21:54:53-07:00
Authentication code: 13

Remove clusters of pixels

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove clusters of pixels

Post by fmw42 »

I don't see any pixel clusters indicated. The second image is totally black in Safari.
Last edited by fmw42 on 2012-05-30T20:12:51-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Remove clusters of pixels

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: Remove clusters of pixels

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Remove clusters of pixels

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply