Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: 3d surface fitting
Date: Wed, 23 Apr 2008 02:42:01 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 31
Message-ID: <fum7lp$sh9$1@fred.mathworks.com>
References: <fum3b2$nc9$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1208918521 29225 172.30.248.35 (23 Apr 2008 02:42:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Apr 2008 02:42:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:464669



"Arjun Chennu" <arjun.chennu@gmail.com> wrote in message 
<fum3b2$nc9$1@fred.mathworks.com>...
> Hi,
> 
> I have a 320x240 pixel grayscale image, which captures the
> intensity profile information of a beam. The beam is a
> nondiffracting bessel beam... and hence, features a bessel
> function distribution in 3D.
> 
> I'm trying to fit a 5 parameter bessel function to the data,
> so that I can extract the bessel parameters. While I've done
> some 2d curve fitting before, I'm not sure how to do 3D
> surface fitting. 
> 
> I tried using lsqcurvefit and some other functions, but
> nothing seems to work. Mainly, I'm not sure how to pass the
> data and the objective function correctly.
> 
> My 5 parameter objective function is:
> 
> a * [besselj(0,b * sqrt( (x-c)^2 + (y-d)^2 ) )]^2 + e
> 
> My image data is a 320x240 array of type 'double'.
> 
> Can somebody please guide me about fitting my data to the
> equation, and producing a mesh of it?

[x,y] = meshgrid(1:240,1:320);
fun = @(c) c(!)*besselj(0,c(2)*sqrt((x-c(3)).^2+(y-c(4)).^2)).^2+c(5);

John