Page 1 of 1

Creating Mask files from connected-compoents

Posted: 2019-05-21T20:12:30-07:00
Given a BW image with several white color regions, it seems connected-components can label regions separately.

How can I create individual region in different mask files for each connected-component regions ?

Thanks for your help.

Re: Creating Mask files from connected-compoents

Posted: 2019-05-21T23:05:15-07:00
by fmw42
Use both -define connected-components:mean-color=true and -define connected-components:keep=list-of-ids. That will export one file for each region that you list. You have to run it once to find the regions you want and then run it again with these commands.


Please always provide your IM version and platform when asking questions, since syntax may differ.

Re: Creating Mask files from connected-compoents

Posted: 2019-05-22T03:44:45-07:00
by snibgo
If you want one image per component, you will need a shell loop after first listing the components. Within that loop, you could re-run the connected components for a single id-number. Alternatively, use the first run to create unique colours, one per component. Then loop through those colours, isolating the colour to make the mask.

The code for this will depend on your shell language, of course.