10-25-2024, 12:18 AM
I see two ways to do this.
Both start by selecting the white in A then getting a path form the selection, as explained previously (because this is the most practical way to separate the blobs in A). Once you have a path you can construct separate paths each with a copy of one stroke from the original (so one path per blob in A).
Then:
My ofn-path-edits script contains many examples of path extraction/splitting and checking nesting.
Both start by selecting the white in A then getting a path form the selection, as explained previously (because this is the most practical way to separate the blobs in A). Once you have a path you can construct separate paths each with a copy of one stroke from the original (so one path per blob in A).
Then:
- The first technique is to use each of these paths in turn to create a selection (so you have a selection mask which is one of the blobs in A) and use the pdb.gimp_drawable_histogram(...) on layer B to check for white (or non-black) pixels (the histogram applies to the selection).
- A second technique is to extract path strokes from B (as you did for A) and check if any of these strokes intersects a stroke in A. Technically, you only need to find an anchor of the stroke of B which is inside a stroke of A. You can very quickly eliminate most candidates by checking that their bounding boxes don't intersect. If you want a bit more accuracy instead of the anchors you can use pdb.gimp_vectors_stroke_interpolate(...) to get a polygon with more summits.
My ofn-path-edits script contains many examples of path extraction/splitting and checking nesting.