It seems easy to locate stars in an astrophotograph: they are the bright dots.
I am recording images of the sky with my Canon EOS 60Da. It has a resolution of 5184 x 3456 pixels (after demosaic) in each of red, green and blue color channels. This is a wonderfully high resolution that exceeds the resolution of the lens and the atmosphere through which it is seeing. A “pinpoint” star is actually around 10 pixels in diameter, more if it is really bright.
And the background is not black. There is light pollution, and when the moon (or eclipsed sun) is near, there is skyglow, and there is always the background noise of the detector. All of these add up and make it more difficult to find the stars, especially if they are dim.
Here is my strategy to detect them, and then to measure their exact sub-pixel positions.
- Establish the local average and local variation of the background sky. This tells me what the average light level is, and the amount of random noise.
- Set a threshold above that noise level and detect everything that exceeds it. These will include stars and “hot pixels” (detector noise).
- Eliminate the isolated single pixels; they are the sensor hot pixels.
- For what remains, these are the “cores” of the star images. Expand the neighborhood around each. Take the weighted average of those pixels and find their geometric center. This is the star’s location in the image.
I wrote a Matlab script to do this, and applied it to various test images I have taken of the eclipse field of stars. It yields (subpixel image) coordinates of the stars it identifies. These are used as inputs to the next step.
Stars detected in each of the three color channels (RGB) for the eclipse field. Not all stars are seen in all channels, and noise creates spurious stars in each channel. This exposure is 1 second at ISO 100, the best signal to noise setting on the camera.
The detected stars found in all three color channels. The double star to the left is Regulus (alpha Leo) and its companion.