From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Guaasian Peak fit results differ from other fiitting software results

Solved!
Go to solution

hi, I am doing guassian peak fit as shown by curvefitting example of labview on an image. But when the same data is fitted through Origin or Matlab the results differ from that of Labview. Can anyone tell me why this is happaning??

Labview user
0 Kudos
Message 1 of 13
(3,229 Views)

Please post: 1. Your data. 2. The results you get from the other programs and from LV. 3. All of the initial settings or parameters used in both the LabVIEW and other programs.

 

Without specific data, it will not be likely that anyone can answer your question.

 

Lynn

0 Kudos
Message 2 of 13
(3,212 Views)

@Aojha wrote:

But when the same data is fitted through Origin or Matlab the results differ from that of Labview.


I what way do they differ? Which software gives a better fit? As Lynn said, we need much more information.

0 Kudos
Message 3 of 13
(3,203 Views)

hi,

I have attached the data in excel format. Along with Labview fit and Origin fit. The Labview fits data with R^2 of 0.94 while Origin fits the same data with R^2 of 0.967. The same thing happens with any other data.

Labview user
Download All
0 Kudos
Message 4 of 13
(3,178 Views)

We also need one more piece of data - what algorithms are you using to fit?  The non-linear Levenburg-Marquart is the obvious choice, but with such noisy data, you may be better off with a downhill simplex using Lorentzian errors instead of Gaussian (see the online Numerical Recipes section on data fitting if you are unfamiliar with any of this).  Also, your data appears to be more peaked than a Gaussian.  It may fit better to a different distribution.

0 Kudos
Message 5 of 13
(3,159 Views)

I agree that the stock Gaussian Peak Fit does not perform well here, but the nonlinear curve fit works fine, with a ~2x better fit. (you just need to write a model)

 

(Even if you give the correct values as initial guesses for the gauss fit, it does not work well. Unfortunately, the inner code is hidden inside a DLL so we cannot probe further where the problem could be.)

 

I would recommend to use the nonlinear curve fit for this. Does it agree with your other methods?

 

Here's a quick VI comparing the two methods. (Modify as needed. It seem Origin defines the width and amplitude differently)

 

 

Download All
Message 6 of 13
(3,134 Views)

Actually the problem is that I am processing an image And I am getting data from that image. Now I have to find sigma and center of Guassian fit. So the data is not known, it varies with image points and I have to fit guassian only.

Labview user
0 Kudos
Message 7 of 13
(3,112 Views)

@Aojha wrote:

Actually the problem is that I am processing an image And I am getting data from that image. Now I have to find sigma and center of Guassian fit. So the data is not known, it varies with image points and I have to fit guassian only.


Sorry, I have no idea what you are trying to say here.

Can you show us such an image and whay you are trying to get out of it?

How does the data you attached earlier relate to an image?

0 Kudos
Message 8 of 13
(3,102 Views)
Solution
Accepted by topic author Aojha

The mismatch between the Gaussian Peak Fit.vi and the Nonlinear Curve Fit.vi results is due to the default parameter bounds of the Gaussian Peak Fit.vi.  By default the bounds force the offset parameter to 0.  Change the upper and lower limit to be +Inf and -Inf, and change the tolerance to be ~1E-8, and the results between the two VIs agree.

 

-Jim

Message 9 of 13
(3,087 Views)

I have attached a n image.

1-I have to count all the bright intensity objects in the image.

2-Calculate centroid of each bright intensity objects and mark its border.

3-plot horizontal and vertical profile for each centorid between object's border.

4-fit guassian curve on the profile and calculate standard deviation.

5-Again plot profile of intensity w.r.t. centroid (for each row and column of bright objects) and fit guassian to calculate standard deviation.

in sort I have to process individual bright objects to get individual spread (source size) and spread of source in whole image (source divergence).

Labview user
0 Kudos
Message 10 of 13
(3,082 Views)