-
Hi Abe If this can be done are you able to also clarify where the origin (0,0) is ? (e.g. is it at the top-left of the image?) and the direction X increases (is it left to right) and Y increases (is it as you go top to bottom?) please! Thank you :-) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Emme, Thanks for the kind words! You're right that the "Extract region properties" option in the Measurements menu just gives the centroid of each segment. Internally, this uses regionprops from scikit-image. you can see the relevant bit of code here: regionprops doc: https://scikit-image.org/docs/0.23.x/auto_examples/segmentation/plot_regionprops.html But yes, for what you're trying to do re-drawing the actual outlines to compute overlap, the centroid alone won’t help. If your goal is to measure overlap between RootPainter segmentations and those from other algorithms (or manual annotations), I suggest doing this directly with the binary masks (working with segmentation files directly). Working with the per-pixel segmentation masks is a bit more standard and straight forward way to compute metrics like IoU, dice, etc. However, if you still want the (x, y) coordinates of the segment boundaries, you can extract them using skimage.measure.find_contours. find_contours will give you the pixel coordinates along the outline of each segmented region. Here's the relevant function: https://scikit-image.org/docs/stable/api/skimage.measure.html#skimage.measure.find_contours I believe you would need to pass the mask as a numpy array, and then find_contours will return a list of contour coordinate arrays. x and y is from top left. So top left of image is (0, 0). Kind regards, |
Beta Was this translation helpful? Give feedback.
Hi Emme,
Thanks for the kind words!
You're right that the "Extract region properties" option in the Measurements menu just gives the centroid of each segment. Internally, this uses regionprops from scikit-image.
you can see the relevant bit of code here:
https://github.com/Abe404/root_painter/blob/1700ed33060e02e94ccfb6b7f9fdd56de4029b7c/painter/src/main/python/extract_regions.py#L40C15-L40C34
regionprops doc: https://scikit-image.org/docs/0.23.x/auto_examples/segmentation/plot_regionprops.html
But yes, for what you're trying to do re-drawing the actual outlines to compute overlap, the centroid alone won’t help.
If your goal is to measure overlap between RootPainter segmentations and thos…