I've added a new G'MIC filter
Arrays & tiles / Extract objects.
It is quite experimental, but seems to be already useful in some situations.
It tries to automatically extract foreground objects from an image with a 'constant' colored background.
The extraction creates as many new layers as there are object detected.
Here is a typical example of use. Suppose you are interested to get each letter from an alphabet that you have found on the web, for instance this one :
Extracting each letter manually is a pain for people like me
And in this case, you cannot extract easily the shapes you are interested in, because they are not placed along a regular grid for instance.
So, now, what I can do is open G'MIC and select filter
Arrays & tiles / Extract objects (of course, you need a refresh to see this filter appearing in your G'MIC) :
Attachment:
gmic_extract_objects.png [ 109.56 KiB | Viewed 9775 times ]
The green dots appearing in the preview is the point that must be set on background, it will define a reference color for the background, used to detect all foreground objects.
You set all the parameters (background point position, color tolerance, minimal size of detected objects, etc..), and you click OK.
And you get :
Attachment:
gmic_extract_objects2.png [ 56.15 KiB | Viewed 9775 times ]
Here, I got 27 layers, i.e. all individual letters + the character.
Of course, this is not working so good when you have more complex backgrounds or shapes, but still it does a quite decent job and I'm sure this can be useful in many situations.
That's it, feel free to test and give feedback on this filter.