Question

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.

streak beside star streak through galaxy

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:

wanted star mask wanted galaxy mask

Thanks! -Adam

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top