Sunday, April 3, 2016

Taking the Halos out of the Heavens





OK!  So we have found the bright stars by using an automated thresholding routine, and we have gobbled them up with a region growing algorithm.  So where we now?

Here is what our example image looks like after having all the bright stars removed.


Bright Objects have Halos



Close, but no cigar.  The bright objects have halos around them, and these halos are themselves much brighter than the dim objects that I want to look at.

This is happening because we have only done region-growing on the pixels that were at the maximum brightness that this image could represent.  But those bright stars and galaxies don't just cut off at 255 in this images.  They fade and fade and fade into the darkness.  Halos.

OK, so here's what we do.  We use our knowledge of where the bright regions are, and knowledge of what the dark image looks like, to get rid of those halos.

We will take a statistic of all the pixels in the image remaining after removing the bright regions.  Then, for each bright region, we will grow its perimeter as a separate region.



Finding the Perimeters of Bright Regions


It's easy to get these perimeters: for every pixel in the bright region, check its neighbors.  If any of them are not in the region -- add them to the perimeter region.  (I suppose that is not the most efficient possible method for large regions.  Exercise for the interested reader.  Or for me if I ever get to do this with a Big Telescope.  An actual perimeter-following algorithm is almost as easy as what I did here.)

Now the fun part.  We have the statistic for the dark image (image with bright regions removed.)  So look at the average pixel value of that perimeter.  If it is more than N standard deviations above the dark-image mean (I think I chose N==1.)  then the perimeter is 'bright'.  Add it to the region.

So we iterate, finding new perimeters and adding them to the regions until the perimeters are not significantly brighter than the dark images anymore.

Here's our image after 5 such iterations:






and after 10.  (Some objects stopped growing a while ago.)






When all regions have stopped growing, we have eliminated all the bright halos!

Here is what our image looks like now:





That is beautiful.   At last we have an image of just the dark stuff.  All the bright stars removed, including their halos.


And now we can threshold this image, and find the bright regions in it.

At last we can detect all of the objects that were really faint in the original image.


The Faint Objects


We are now only a couple steps away from paydirt: the detection of moving faint objects.



No comments:

Post a Comment