Does anyone have a tried and true auto exposure and auto gain routine that they've used on their sky images? I would like to implement something that has been proven to work on the sky instead of writing my own.
Here are my ideas:
1) Assuming the focus is already close, take an image with a trial exposure time and gain. For this algorithm, the exposure time would be kept constant and the gain is varied. The exposure time is change only if changes in gain is not enough to get the counts where we want.
2) Take a histogram of the pixels.
3) If there are saturated pixels, ignore them. Otherwise, take the brightest pixel value that is not next to saturation (253 counts for an 8 bit monochrome image), then increase gain by a little until the counts are up close to saturation.
4) Otherwise, decrease gain until the non-saturated pixels are just below saturation (253 counts)
5) If the gain goes to 0, and the image is still saturated, then this means the exposure time needs to decrease so decrease some.
6)If the gain goes to max, then this means that hte exposure time is too short so increase the exposure time some.
7) Repeat until the histogram is full from left to right with the maximum pixels that arent saturated are just less than saturation.
Does anyone else have something that might work better? I think I would be brute forcing it using this routine so I would like to try something more efficient or robust if anyone knows something better!