7 Replies Latest reply: Nov 23, 2009 1:48 AM by 791266 RSS

    2D Gauss fitting

    843853
      Hi !

      I have a matrix 11x11 and I need a 2D Guassian Fitting algorithm !
      Does anyone know where i could find one ?

      Thanks
      Felix
        • 1. Re: 2D Gauss fitting
          796254
          cross post
          • 2. Re: 2D Gauss fitting
            796254
            Sorry, I thought I'd answered this one somewhere else.

            Check out "Numerical Recipes" by Bill Press et. al. It's got a lot of info on curve fitting.

            What did a Google search bring you? - MOD

            • 3. Re: 2D Gauss fitting
              843853
              Didn't find anything apropriate in the Numerical Recepies...
              And in the google search only software sites show up... No 2D Gauss Fitting algorithm ! Is there any source in C, Java or MatLab out there ?

              Felix
              • 4. Re: 2D Gauss fitting
                843853
                What about finding the means and standard deviations of the xs
                and ys, and the correlation between them? Then the Gaussian is
                given by the simple formula
                f(x, y) = exp(      ((x-xbar)/sx)^2
                              + 2*r*((x-xbar)/sx)*((y-ybar)/sy)
                              +     ((y-ybar)/sy)^2
                             )
                          /((2*pi*sx*sy)*sqrt(1-r^2))
                if I remember rightly (but I would check it :-)

                If your matrix consists of frequencies, use weighted averages
                etc. E.g. xbar = sum over rows (x * sum over columns (f[i,j]))),
                sx = sqrt(sum over rows ((x-xbar)^2 * sum over columns (f[i,j]))).

                I assume the data is frequencies, but you don't say.
                • 5. Re: 2D Gauss fitting
                  843853
                  If your matrix consists of frequencies, use weighted
                  averages
                  etc. E.g. xbar = sum over rows (x * sum over columns
                  (f[i,j]))),
                  sx = sqrt(sum over rows ((x-xbar)^2 * sum over columns
                  (f[i,j]))).

                  I assume the data is frequencies, but you don't say.
                  Sorry, I meant f[i, j] to be scaled so that there sum is 1.
                  Otherwise divide the averages by the sum of f[i, j].
                  • 6. Re: 2D Gauss fitting
                    843853
                    jhepwork http://jwork.org/jhepwork/ has an example
                    of how to fit 2D Gaussian using the chi2 minimisation
                    • 7. Re: 2D Gauss fitting
                      791266
                      Sergei175 wrote:
                      jhepwork http://jwork.org/jhepwork/ has an example
                      of how to fit 2D Gaussian using the chi2 minimisation
                      Don't resurrect old threads. I'm locking this thread.

                      Kaj