views:

610

answers:

3

I have two questions concerning fitting a gauss curve to histogram peaks. My first question is a very basic one:

  1. How can I fit a gauss curve to a entire histogram? Does this only mean that I have to find out and calculate the mean value(µ) and the deviation(ϭ) of the histogram and put them into the formula for the Gauss curve?

Would the following example be right?: Assume (just as an example) I have a histogram of an image with 5 colour values. On the X-Axes there are these 5 color values and on the Y-Axes there are the frequencies of each of these values. i.e.:

value 1: 1 time

value 2: 4 times

value 3: 7 times

value 4: 3 times

value 5: 2 times

Now the mean value(µ) would be 3(µ = 3).

And the deviation(ϭ) would be 0.9 (ϭ = 0.9). formular:

Now I use these values in the formular of the density function to calculate my gauss curve?

Is that correct? Unfortunately I am a little unsecure about the math background.

  1. My second question is a little more tricky: This time, I have a histogram with several peaks, but I only want to fit the gauss curve to the highest peak. So, I go through all the bins of the histogram with a simple for loop and find one intensity value on the x-axis(which contains the intensities of the image) with the most frequencies(shown on the y-axes). This would be the highest peak. But how do I find out the deviation? Especially, since I dont know which of the intensity values I should include in my calculations. As far as I know the turning point of the gauss curve lies at µ+ϭ and µ-ϭ. Could that help to solve the problem.

I am sorry that this question is a little mathematical, but I did not find a better place to ask it. I also read some similar topics, but unfortunatley they did not finally answer my question.

Thanks for your help!

Regards Marc

+3  A: 

Your simple approach for a single peak should be OK. [BTW I think this is properly a programming question if it relates to images.]

Multiple peaks are more difficult. The process of resolving peaks is called deconvolution (http://en.wikipedia.org/wiki/Deconvolution) and there is not normally a unique answer. You may have to decide how many peaks there are, or what the minimum variance of a peak is (otherwise you could create a peak for each bin :-)).

peter.murray.rust
I think deconvolution only would solve the problem if all gauss curves have the same variance
nikie
No, but it certainly makes it easier. You don't say what your multimodality is caused by, but I would expect that multiple peaks were roughly isovariant
peter.murray.rust
+1  A: 

Thank you for your reply! That is exactly my problem. Do you mean that there is no definite variance for a certain peak? So I can only define this variance by my own? Probably I receive my minimum variance of a peaks by defining a peak-bin as beeing surrounded by two lower bins to its right and left(or X lower bins to the left and right). Would this be an appropriate approach?

I took a look at your and some continuative links, but have troubles to understand it. Is there probably an easier description somewhere. Or can you probably give me a simple explaination what the starting point for my problem is or rather what the steps are that I have to perform.

Regards Marc

Marc
outis
+2  A: 

Your approach to estimating the parameters of a single gaussian is correct, I think.

For multiple gaussians, you might want to look up mixture models or more specifically mixtures of gaussians. Just a few notes on that:

  1. (you probably already knew that) the strongest gaussian in the mix doesn't have to be the one with the highest peak
  2. If you have a sum of two gaussians with different average, the peaks in the histogram won't match the averages
  3. Using the height of a single peak in a discrete histogram probably isn't a good idea: The actual peak might be in between the two histogram bins. [Clarification: In that case, the count in both bins can be significantly lower than for a peak that's centered in a bin.] Also, for most kinds of data, your histogram will contain a lot of noise. At least use some kind of averaging filter over the histogram.
nikie