LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d Gaussian Fit Problem.

Solved!
Go to solution

I am having problems in fitting a 2d gaussian curve.

 

I have a set of data: with 3 columns and N rows. For example 

x    y    Intensity.

..   ..      ..

N is same for all 3 columns. I am trying to create an intensity plot out of this data and fit a 2D gaussian to it. 

 

I tryed making a polynomial interpolation of the intensity data over the x-y range and make an intensity plot (Don't know if there is a better way of doing it ! Please Suggest if there is any other way.).

 

Then I use Levenberg-Marquardt method to fit this data. For some reason, it is not doing any iteration with the initial guess. The best fit value is same as initial guess. it is shoing error: NI_Gmath.lvlib:LM get new coefficients.vi:1. (see attached vis)

 

Can anyone help me with this !

 

Thanks.

0 Kudos
Message 1 of 24
(9,031 Views)

You don't need to interpolate the data into a regular grid, all you need is fit for the existing points.

 

Have a look at my old example here (look for the "random" option.

 

Your attachment is missing quite a few subVIs. can you attach them too? Thanks!


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 24
(9,023 Views)
Solution
Accepted by topic author babu126

OK, I quickly modified my old example and it seems to easily fit your raw data. See attached (LV2010). Modify as needed.

 

(Note that I define the width as "width at half heigh", your definition might differ.)

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Download All
Message 3 of 24
(9,018 Views)

The new gaussian peak fit vi has several nice features such as choice of fitting algorithm, entering pre-determined parameters or bounds, etc.  Would it be possible to use it in your gaussian fit program and if so, could you show how to make the modification?

 

Thanks, very useful and efficient code!

0 Kudos
Message 4 of 24
(8,525 Views)

@Tim_W wrote:

The new gaussian peak fit vi has several nice features such as choice of fitting algorithm, entering pre-determined parameters or bounds, etc.  Would it be possible to use it in your gaussian fit program and if so, could you show how to make the modification?



Which "new gaussian peak fit" are you talking about?

You would enter paramter guesses in the controls already given.

If you want to set paramter bounds, substitute Constrained Nonlinear Curve Fit VI and add a control for the additional inputs.

What other fitting algorithms do you have in mind?


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 24
(8,516 Views)

Under Math VI\Fitting VI\Gaussian Peak VI.  I'm not sure how new it is-it's new to me, but may have been around for awhile.

0 Kudos
Message 6 of 24
(8,513 Views)

@Tim_W wrote:

Under Math VI\Fitting VI\Gaussian Peak VI.  I'm not sure how new it is-it's new to me, but may have been around for awhile.


This is only for a plain 1D gaussian, not 2D as in my example above.

 

The "Constrained Nonlinear Curve Fit" mentioned above also has inputs for the "method", so you should be able to do whatever you want (method, paramter bounds, etc.) once you supply a model.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 7 of 24
(8,508 Views)

Actually, because I couldn't manege how to use your .vi, I did an other post with the same question and another one.

0 Kudos
Message 8 of 24
(8,487 Views)

@MateusV wrote:


What is "not loading"? Can you be more specific?

 

We should keep all this in one place, so let's continue the discussion here.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 9 of 24
(8,478 Views)

Dear 

 

I come across your post and I  tryied it on with my spot image after replacing your simaluted data with the 2d image.

 

but I could not get it to work.   did I miss something or not use it correctly?

 

attached please find the test code.  would very appreciate your help.

 

cheers

 

xg

 

 

0 Kudos
Message 10 of 24
(7,759 Views)