I have a visual marker like this one and a blob detection algorithm in Java .. How can I extract the regions of the image so that I can run the blob detection algorithm on each one separately so that it can detect 1, 1, 3 blobs respectively.
Thanks a lot in advance !
That's a fun detection game. You will need a few morphological tools so as to solve it.
Since your goal is to detect valid d-touch pictures, you may want to organize your analysis differently. For example, with Mathematica:

Detecting whether a black region encloses at least 3 white regions by filling the holes of the image and counting the number of connected components:
Max@MorphologicalComponents[
FillingTransform[DeleteBorderComponents@img]] >= 3

Detecting whether half of these white regions contain one or more black regions can be done by counting holes inside each white region:
comp = ComponentMeasurements[DeleteBorderComponents@img, "Holes"];
2*Count[comp, _ -> n_ /; n > 0] >= Length@comp

Detecting whether there are further levels of nesting can be achieved by querying for the number of enclosed components:
Count[
ComponentMeasurements[DeleteBorderComponents@img, "EnclosingComponentCount"],
_ -> n_ /; n > 0] == 0

Some of the operations above may be tricky to implement in Java. I shall pass on that one -- done with the fun part!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With