LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2-D nonlinear curve fitting

Hi everyone,

 

I have the same problem but I need an isotropic 2D Gaussian fit to fit the image of a spot.

Is it an existing VI for this?

 

Gabriel

0 Kudos
Message 11 of 63
(4,121 Views)

The problem has already been solved in this thread. Take my example above and surgically remove the code for the angle and the second width to make it isotropic. (Use the first width for both dimensions). These are minimal changes. The model will have two less parameters.

 

See how far you get....

Message 12 of 63
(4,117 Views)

Hello,

 

This example VI appears to be exactly what I need to profile a laser beam using a webcam. Unfortunately I only have labview 8.5. Is there anyway you can post a picture of the block diagram? I have been struggling to use the nonlinear curve fitting vi's supplied with labview to treat two dimensional data instead of simple 1D data. How do you adapt your 2D data to be processed by a 1D fitting algorithm?

 

Thanks very much, Arron 

0 Kudos
Message 13 of 63
(4,075 Views)

Hi MenI,

 

If you download the VIs you can upload them to the Downconvert forum (http://forums.ni.com/t5/LabVIEW/Downconvert-VI-Requests/m-p/1067229?requireLogin=False) and have someone downconvert these files for you.

 

Regards,

Daniel H. 

0 Kudos
Message 14 of 63
(4,039 Views)

Maybe a bit late, but for the people who happen to read this thread:

 

First of all, huge thanks to Altenbach for this VI and the explanation! It helped me a lot (i tried to make my own 2D Fit program and was looking for some kind of inspiration).

 

But there's a little (but crucial) mistake in your formula for calculating a gaussian disribution:

 

You forgot a factor of 2 in your model vi. The correct formula is exp(-2*x²/w²), yours is exp(-x²/w²). Both are correct. But when you calculate a power distribution (e.g. the intensity array of a CCD) you have to square your gaussian distribution (Intensity I = E²).

 

 

0 Kudos
Message 15 of 63
(3,835 Views)

@Tjalf wrote:

You forgot a factor of 2 in your model vi. The correct formula is exp(-2*x²/w²), yours is exp(-x²/w²). Both are correct. But when you calculate a power distribution (e.g. the intensity array of a CCD) you have to square your gaussian distribution (Intensity I = E²).


 

(quote from my post above: "... and the principal Gaussian widths are defined as 2*sigma for code simplicity"), so I documented that I took some shortcuts, even if the statement is not exactly correct ;))

 

All my gaussians are typically defined as width at half height, yet another convention. 😄

0 Kudos
Message 16 of 63
(3,830 Views)

Ah I see. Damn all those conventions! 😄 They're freaking me out everytime I have to do something with gaussians.

0 Kudos
Message 17 of 63
(3,821 Views)

I used some parts of the VI posted above to fit a 2D Gauss to my data. I get the -20041 error "The system of equations cannot be solved because the input matrix is singular.". As far as I know this is caused by using bad initial parameters, how to fix this?

0 Kudos
Message 18 of 63
(3,764 Views)

@nikodem wrote:

I used some parts of the VI posted above to fit a 2D Gauss to my data. I get the -20041 error "The system of equations cannot be solved because the input matrix is singular.". As far as I know this is caused by using bad initial parameters, how to fix this?


A typical mistake is if the size of the array of initial parameters does not match the number of parameters used in the model.

Does the function look OK if you calculate the model using your initial parameter estimates? Does it behave as expected if you change any of the parameters?

 

Can you attach your code?

0 Kudos
Message 19 of 63
(3,754 Views)

The size of the initial parameters array is six, the same as the a array in the function f(x,a) that I try to fit. I attach my VI, but unfortunatelly I can not attach my data (that is read by the SIF READER subVI.

0 Kudos
Message 20 of 63
(3,749 Views)