简体   繁体   中英

using python to pick out morphology of different pieces on an object in an image

I have an image-analysis/morphology question and I need a python-based solution. I'm an astronomer trying to mask the cosmic ray tracks (streaks ranging from 1 to 100 pixels long) out of my images. I pick out the tracks using a filtering technique with a threshold. It works pretty well except when the track runs into an object (a star or a galaxy). As you can see below I end up with blobs (like the one in the left image) and rings (like the one in the right image) along my track.

明星旁边的条纹穿过星系

In these images you can ignore the squiggly lines and the while "X"'s, the black boxes are my masked pixels. What I would like to do is separate the tracks (long streaks) from the blobs and rings (FYI, the rings show up because the filtering raises the significance of the edges of objects). So my question is how can I classify the morphology of certain parts of the mask and separate the blobs/rings from the track.

In case this makes answering the question easier, here is the mask for the image on the left:

spots=array([[False,False,False,False,False,False,False,False,False,False,False],
   [False,False,False,False,False,False,False,False,False,False,False],
   [False,False,False,False,True ,False,False,False,False,False,True ],
   [False,False,True ,True ,True ,True ,False,False,False,True ,False],
   [False,False,True ,True ,True ,True ,False,False,True ,True ,False],
   [False,False,True ,True ,True ,True ,False,True ,True ,False,False],
   [False,False,False,True ,True ,True ,True ,True ,False,False,False],
   [False,False,False,False,False,True ,True ,True ,False,False,False],
   [False,False,False,False,False,True ,True ,False,False,False,False],
   [False,False,False,False,True ,True ,False,False,False,False,False],
   [False,False,False,False,True ,False,False,False,False,False,False],
   [False,False,False,True ,False,False,False,False,False,False,False]])

Ideally I'd like to have the tracks masked, and when they completely intersect with an object, like in the right image, I'd like to mask the entire track, through the object, without masking the portion of the object that is unaffected by the track. So I would like the final masked result to look something like the white tracks shown here:

想要明星面具想要星系面具

Thanks! -Adam

If i have understood the problem right you would like to keep the blobs while removing the long strands that pass around or through the object. The simplest test i would suggest is using a simple morphological opening (erode and then dilate) that has a radius larger than the thickness of the strands but smaller than that of the blob. Examples can be seen here . And ofcourse the openings can be tried in grayscale which will produce better results than just operating on a single level set threshold. I guess this can be easily located in Scikit .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM