# LabVIEW

cancel
Showing results for
Did you mean:

## Re: 2-D nonlinear curve fitting

OK, the Gaussians in the x and y direction are the same, but both are asymmetric, with a different width on each side. (in the more general case, you would need four widths)

Here's my 5 minute modification (fitsurface4.zip). See if it works for you. I am not sure if it is exactly what you want. (there are probably bugs)

Since there is significantly more asymmetry now, there are probably local minima in the rotation, so you might have to add some more intelligence to get a good angle guess.

(To simulate other data scenarios, make the "guess" array into a control and vary any parameter at will, then look at the middle graph, e.g. fitsurface3.zip)

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

## Re: 2-D nonlinear curve fitting

this same problem is mine  ihave an image of bead and i have to its center ,but cant able to do this i have labview 11

It is not important to know all the answers, what is important is how to find them
Message 32 of 63
(923 Views)

## Re: 2-D nonlinear curve fitting

@abhishek_singh wrote:

this same problem is mine  ihave an image of bead and i have to its center ,but cant able to do this i have labview 11

What have you tried and what kind of errors did you encounter?

Attach your code and your data so we can see what's wrong.

LabVIEW Champion Do more with less code and in less time
Message 33 of 63
(918 Views)

## Re: 2-D nonlinear curve fitting

Dear Altenbach,

First of all like the others here I want to thank you for your tricks which allowed me to build an efficient 2D fitting algorithm for my experimental data. I would now have interest in getting confidence intervals for the different fitting parameters and I was trying to use the built-in labview VI Nonlinear curve fit intervals, but it seems that it does not respond very well to having no X input (unlike the nonlinear fitting VI). I also tried it unsuccessfully with your 2D gaussian fitting code.

Do you have suggestions as to how to treat this problem?

Thank you very much in advance,

Antoine

Message 34 of 63
(745 Views)

## Re: 2-D nonlinear curve fitting

Please disregard the previous message, th eproblem was actually the same as pointed out in the thread http://forums.ni.com/t5/LabVIEW/Non-linear-Fit-Intervals-Gives-Error-20001/td-p/1301484.

Message 35 of 63
(718 Views)

## Re: 2-D nonlinear curve fitting

Dear altenbach,

Dear All,

thank you for your help on 2D fitting.

I think that the version 2 (FitSurface2.zip ‏40 KB) should be the best approach for my problem.

I have a spot that should be gaussian (it should be better to use a Pseudo Voigt, i.e. something similar to µ*F_gauss + (1-µ)*F_Lorentz) that should be elliptical and rotate.

However, during an experiment I can obtain a saturated image...

In order to not loose all the experimental run, I would like to fit the spot making a mask (or better not fitting the saturated areas). The vi FitSurface2 transform 2D to 1D: in this way it is possible to fit (for each line) only the tails, discarding the saturated points.

But, how I can do it in Labview? (I can do with Origin, Kaleidagraph...)

awaitig some helps...

dh

Message 36 of 63
(575 Views)

## Re: 2-D nonlinear curve fitting

I believe Altenbach's fit is a general 2D non-linear fit to a (more-or-less arbitrary) model.  If you want to fit, but your data is saturated, make a model of "saturated data".  In your case, the model would be min (Gaussian model, Saturated Value).

Bob Schor

Message 37 of 63
(545 Views)

## Re: 2-D nonlinear curve fitting

Dear Bob,

I'm sorry but I do not understand "make a model of "saturated data" "

dh

Message 38 of 63
(537 Views)

## Re: 2-D nonlinear curve fitting

@Dariush_Hampai wrote:

Dear Bob,

I'm sorry but I do not understand "make a model of "saturated data" "

I am sure that a saturated 2D gaussian can be modeled mathematically, maybe with just one additional parameter that describes the saturation. So simply add one more parameter, rewrite the model subVI according and fit for it.

If you have problem with that, please attach some typical data.

Is the saturation some nonliear process or is it just an input clipping? Is the saturated value known (e.g. 255, or whatever the Z resolution of the deterctor is)

LabVIEW Champion Do more with less code and in less time
Message 39 of 63
(531 Views)

## Re: 2-D nonlinear curve fitting

Dear Altenbach,

in my attach you may find your example with my saturated image

FitSurface2.zip ‏242 KB

Message 40 of 63
(527 Views)