LabVIEW

cancel
Showing results for
Did you mean:

Re: 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

Message 11 of 63
(1,584 Views)

Re: 2-D nonlinear curve fitting

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....

LabVIEW Champion Do more with less code and in less time
Message 12 of 63
(1,580 Views)

Re: 2-D nonlinear curve fitting

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

Message 13 of 63
(1,538 Views)

Hi MenI,

Regards,

Daniel H.

Message 14 of 63
(1,502 Views)

Re: 2-D nonlinear curve fitting

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²).

Message 15 of 63
(1,298 Views)

Re: 2-D nonlinear curve fitting

@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.

LabVIEW Champion Do more with less code and in less time
Message 16 of 63
(1,293 Views)

Re: 2-D nonlinear curve fitting

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

Message 17 of 63
(1,284 Views)

Re: 2-D nonlinear curve fitting

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?

Message 18 of 63
(1,227 Views)

Re: 2-D nonlinear curve fitting

@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?