photutils icon indicating copy to clipboard operation
photutils copied to clipboard

ImageSegmentation: include option to provide pixel coordinates and extract the segment that corresponds to it

Open shruti-ramaiya opened this issue 2 years ago • 2 comments

Image Segmentation is useful for masking sources in an astronomical image and sometimes this masking option involves having to remove certain segments e.g. galaxies in the image before creating a source map of the remaining sources. It may be useful to add an option to add an method to ImageSegmentation that allows the user to provide pixel coordinates and extract the segment in the image, as well as its label, so it can be easily removed. Something like the bbox functionality but allows for more ease of removing segments

Thank you

shruti-ramaiya avatar Jan 26 '24 08:01 shruti-ramaiya

You can remove segments from a segmentation image by simply using the remove_labels method: https://photutils.readthedocs.io/en/latest/api/photutils.segmentation.SegmentationImage.html#photutils.segmentation.SegmentationImage.remove_labels

If you want to know the label number for a given (x, y) position, index the segmentation map in the normal Python way: label = segmap.data[y, x]

larrybradley avatar Feb 09 '24 16:02 larrybradley

Thank you for letting me know about how to find the label for a given x,y -I will try this

shruti-ramaiya avatar Mar 01 '24 11:03 shruti-ramaiya