From: John Kuehne on 21 May 2010 12:56 Logarithm-to-linear least squares methods can work quite well for determining the centroid and sigma of a 2-D Gaussian, including images where part of the Gaussian is masked out, when the Gaussian is floating in a sea of noise, e.g. an image of a star. The key is to remove the noise floor, leaving only pixels that are appreciably signal. CCD noise is a complicated mixture of things, and a science unto itself, but in the end CCD noise - e.g. readout, shot, dark, and sky brightness - looks pretty much like a Gaussian sea - a plane with pixels tossed randomly above and below it, narrowly bounded. Starting near the top of that sea, simply detect singleton pixels with the convolution matrix [1 1 1 1 -1 1 1 1 1] and raise the noise floor until no more singleton pixels remain. You can also substitute -2 or -3 in the matrix to detect double and triple shot pixels, although these can be connected corner or edgewise to other pixels for this 3x3 detection matrix. What you are left with is the just the data, floating on zeros. If your Gaussian is cut by a slit, for example, just mask this out to zeros. Now you can safely form the least squares matrix and solve for the centroid and sigma. You can also constrain the sigma as a parameter to get just the centroid. Problems: if you have stray pixels in your image that didn't get snipped out, obviously these are going to bias you results. Remember, you're fitting a paraboloid, and stray points are going to pull hard. If A^T * A is not invertible, you'll know it. And if the sigma is not positive, obviously the result is bad. You can also sanity check your result to make sure it's within the data pixels - a centroid that lands in the zeros surrounding your image isn't correct. A few dozen lines of Matlab. There are non-linear least squares methods for Gaussian data. They are recursive, complicated, and sensitive to the initial guess. Have fun. Leave this to the nuts doing aperture photometry. As the other John (I think) mentioned, logarithms turn the scale factor of your 2-D Gaussian into a vertical shift of the paraboloid, putting all pixels in your data on even footing. This can be a good thing - why should I trust bright pixels more than dim ones? Carefully removing the noise floor is the key to good results with least squares. If you can't remove the noise floor, or your data don't fit this model, then go with quasi-statistical methods like 2-D convolution via 2-D FFT to find the centroid. TMW has some nice example of that in their image toolbox.
|
Pages: 1 Prev: Input a filename, then load the file Next: How to make a multi-column legend? |