Segmenting an image using a mask

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

Re: Segmenting an image using a mask

Post by fmw42 »

Anthony wrote:You could use multi-crop on your mask to get that data!
I don't see how multicrop will get those coordinates without doing the floodfill, etc to extract any one white rectangle. Multicrop just looks for one pixel that is red (not none) and uses that to do the floodfill. Am I missing something interesting?

Seems like one would need to convert the mask image into txt format and analyze that into rectangular areas to get the bounds.

But if one has made a mask by drawing rectangles, then why are those coordinates not already known. Then one could just loop over the bounds of each rectangle and use -crop. What am I missing? Are the areas not always rectangular -- perhaps it is because they are slightly rotated so that -crop results will need to still be -deskew or as in my unrotate script -- or can these areas be arbitrary shapes?
Post Reply