Page 2 of 2

Re: Using connected components tool

Posted: 2016-12-05T19:31:05-07:00
by fmw42
The use your area threshold. Then get the list of ids left behind that are gray(255) (using my negated mask). Then use the keep on all those ids and save to png. You will get multiple mask images for each id. Then use the mask images as I did above on the original image and you will get each leaf separately. Or just do edge processing of each mask to get the outlines.

I do not understand why you why you want id 0! I did not suggest that.

Perhaps you should explain a bit more or show me a manually created example of what you want as the end product.

As long as you have removed the stripe on the right, some maximum threshold area should remove all smaller objects as I did above. If your leaves are all about the same size, then one area threshold should work for all images. If not then you will have to stop an analyze the listing once to find the area threshold for each image and then use that in a second command to do the filtering.

Re: Using connected components tool

Posted: 2016-12-06T06:02:41-07:00
by tmelorc
I was thinking (probably wrong) that working with id0: only could be easier to collect only the components with leaves. But I am learning a lot now.

The final result I'd like to get is, for each image foo.jpg a sequence of images foo_{1,2,3...}.jpg one for each leaf, in white background and the leaf with solid black. Later I'll apply something to extract its contour.
The problem is that the leaves area is not so uniform. So I have to filter using some tool, maybe id or rectangle. I'm working on this.

Thanks and regards.

Re: Using connected components tool

Posted: 2016-12-06T10:01:18-07:00
by fmw42
Create the filtered binary mask as before and then crop it once for each bounding box other than for id=0.

Re: Using connected components tool

Posted: 2016-12-14T18:12:40-07:00
by anthony
To distinguish between the leaves and other parts I would look at using morphology on the mask image.
This is actually what morphology was designed originally to do.. find objects of particular characteristics.

First I would look at closing any small 'holes' that might be in the leaves, then do something like a erode to find the larger 'leaf' objects.

See the find large circles' example (do may not need to use the conditional dilation part)
http://www.imagemagick.org/Usage/morpho ... onditional