0

I am working with a contour plot in Python and each nested segment of the plot represents a region of interest (ROI) for me. I would like to extract the highest level of the nested segments in a pythonic way. Please find attached an image of the problem itslef:

In this contour plot generated with seaborn I want to extract the segments regions in red.

The code shall work both when there is a single ROI or multiple ROIs like in this example.

Currently, I am comparing the center of mass of each density/frequency level to discriminate ROIs based on their center of mass. When segments are concentric I select the smallest one as the segment of interest.

However, I feel like there might be an easier way to accomplish this.

Does anyone have any suggestions for a more efficient or straightforward approach to extracting the highest level of nested segments from a contour plot in Python? Thank you in advance for your help.

0 Answers0