I am trying to use autocrop_components to extract into single images the already computed connected components present in an image (segmentation result), as shown below (colored with map 2,2). It seems that adjacent components are not split, like the two in the second panel - using either low or high connectivity gives the same result. Is this the expected behavior?
Thanks! I was thinking differently, as in extracting the already computed connected components into single images, a task commonly done in image analysis. Probably would be something called autocrop_labels
Hmm, this code gives me a idea to shorten all of this into a single command code or maybe even modify rep_colors_freqstat to do 5 single things (it has 4 things). You can literally make a new command using colormap code as well to do this. Lots of ideas thanks to your code.
Thanks for the interest. I wish it was that incredible
This is related to image segmentation where each connected component has a distinct label. I want to do some statistics on each labeled region, e.g. its size (width, height, diameter), area, etc. and also be able to solve a PDE on each. Separating all segmented regions just makes downstream processing easier. The regionprops function in Matlab and in python’s scikit-image are handy for that, though it doesn’t help solving the PDE.
In the solution above, I assume split_colors adds an alpha channel to result images so colors can be easily displayed within a transparent background, not something I need but I am glad remove_opacity is there! Maybe in the future we can have a flag on split_colors to disable the alpha channel (?).
Not sure about this idea. Because split_colors considers also pure black as a valid color to split, and in this case, only the alpha channel is actually useful (the rest is 0 everywhere).
I see the problem when black needs to be also considered. I was not considering pure black as of interest in my case, in a similar manner as in the other commands area_fg and label_fg. The alpha channel is only useful for the black pixels, which generates a single image out of possibly hundreds in my case.
My current hack to keep background represented by pure black is (couldn’t find yet a case it breaks)