# Math Help - How do I practically apply Gaussian Distribution to an array of pixel brightness?

1. ## How do I practically apply Gaussian Distribution to an array of pixel brightness?

Hi All,

I've got a 2-dimensional array of data (x,y) consisting of floating point numbers. These numbers each represent brightness in a star field.

That said, I need to perform a function called "Auto Aperture" on the data based on a point that is clicked in the image/data. I need to execute the following:

Click on a star. App runs "Find" function (gaussian fit) to get coordinates of star and "centroid" (or axes) function and calculates 3 times the FWHM from centroid - and that's Star Radius. For Sky Radius value is 6x FWHM. Then it runs Aperture function using those values for Star Radius and Sky Radius.

I understand how to calculate the centroid and the aperture manually, given the proper radii, but I have no idea as to how any Guassian function applies to the pixel array. I mean, what does the Gaussian function actually find in relation to any other point? What does it mean in English?

If anyone could provide a bit of feedback on this, it would be most appreciated. Some info on practically deriving the FWHM would be nice too.

Regards.

2. Originally Posted by gberz3
Hi All,

I've got a 2-dimensional array of data (x,y) consisting of floating point numbers. These numbers each represent brightness in a star field.

That said, I need to perform a function called "Auto Aperture" on the data based on a point that is clicked in the image/data. I need to execute the following:

Click on a star. App runs "Find" function (gaussian fit) to get coordinates of star and "centroid" (or axes) function and calculates 3 times the FWHM from centroid - and that's Star Radius. For Sky Radius value is 6x FWHM. Then it runs Aperture function using those values for Star Radius and Sky Radius.
I understand how to calculate the centroid and the aperture manually, given the proper radii, but I have no idea as to how any Guassian function applies to the pixel array. I mean, what does the Gaussian function actually find in relation to any other point? What does it mean in English?

If anyone could provide a bit of feedback on this, it would be most appreciated. Some info on practically deriving the FWHM would be nice too.

Regards.
You fit the pixel values to a Gaussian (assume equal variance in x and y
directions for simplicity), then use the bivatiate Gaussian density to find
FWHM.

So lets assume the pixel coordinates in a neighbourhood (set so that the
star is the only significant source in the neighbourhood) of the star are:

$\bold{x}_i=(x_i,y_i), \ i=1,..,n$

and the pixel values are $p_i, \ i=1,..n$.

Normalise the pixel values so that $\sum_{i}p_i = 1$.

Now the centroid is:

$
\bar{\bold{x}}=\sum_i p_i \bold{x}_i
$

$
\mbox{cov} (\bold{x})=\sum_i p_i (\bold{x}_i-\bar{\bold{x}})^T (\bold{x}_i-\bar{\bold{x}})
$

and this is a $2 \times 2$ matrix. We assume that the off diagonal terms are zero
and that the on diagonal terms are equal, and set:

$
\sigma=\sqrt{(\mbox{cov}(\bold{x})_{1,1}+\mbox{cov }(\bold{x})_{2,2})/2}
$

Now you use a Gaussian density with zero mean and SD equal to $\sigma$
to find the FWHM.

ZB

3. Alright,

Thank you for that post. Some questions still:

1) How do I find the mean of an area in which I do not know the number of pixels are included? I've run this function in existing programs and the behaviour varies depending on the area clicked in the image. Sometimes it will determine the area of interest to be as small as one pixel, and other times it might a radius as large as 40 pixels.

2) What exactly am I looking for to stop my progressive search? What if a user clicks just outside a star and surrounding values are actually higher than the "base" pixel clicked? Do you raise the current max (and by extention the mean) and begin searching from there?

As you can see, I'm still a bit confused as to what is *truly* supposed to be accomplished from this.

4. Originally Posted by gberz3
Alright,

Thank you for that post. Some questions still:

1) How do I find the mean of an area in which I do not know the number of pixels are included? I've run this function in existing programs and the behaviour varies depending on the area clicked in the image. Sometimes it will determine the area of interest to be as small as one pixel, and other times it might a radius as large as 40 pixels.

2) What exactly am I looking for to stop my progressive search? What if a user clicks just outside a star and surrounding values are actually higher than the "base" pixel clicked? Do you raise the current max (and by extention the mean) and begin searching from there?

As you can see, I'm still a bit confused as to what is *truly* supposed to be accomplished from this.
I don't know how your system selects a neighbourhood of the star. If it
is user selected it should be several times the dimensions of the star of
interest, and constain no other starts. You could automate the process
by setting the region so that at the edges the maximum pixel value is 1/100
(or 1/1000 or what ever works) of the maximum pixel.

Also I am assuming that dark frame subtraction and flat feilding has already
taken place.

There is still the background light in the frame to worry about, which can in
principle be removed, and I am assuming that if this is necessary it has already been done.

It might be that you want to fit a more complex model, where the star has a
Gaussian like spread embedded in a background which may be relativly high, in
which case some non-linear least squares model fitting may be appropriate.

ZB

5. ## About to throw a Gaussian fit. ;)

To my knowledge, neither dark frame subtraction nor flat fielding have taken place. As far as I know, this is basically the raw image data. That said, running similar functions on different apps does in fact include other stars in the "auto aperture" calculation. They seem to say "keep going until you find pixels that drop below this threshold, no matter what else you find in the interim".

I suppose my problem at this point is being able to determine what that threshold is. I mean, when do I stop sampling from the point chosen? Being as the pixels vary so wildly (even in small neighborhoods), a threshold of 1/100th doesn't really mean anything. A starting pixel could have a brightness value of 6000, then -- not a radius of 3 pixels later -- another is found with a brightness of 40. But in the big picture it's still part of what (at least visibly) appears to be the same star. Bad data perhaps? *shrug*

That said, could you put Gaussian in plain english. I mean in this particular case, is it basically "a center pixel and all surrounding pixels such that the center pixel appears to be the source of emitting light"? Just what does the Gaussian function find?

FYI, I'll be using a "walker" function to walk outwardly from the center point chosen, around and around, until I find whatever I'm looking for.