Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

2D Gaussian fit

510 views
Skip to first unread message

zha...@gmail.com

unread,
Apr 26, 2012, 5:31:48 AM4/26/12
to
How can I fit a spot on an image to a 2D Gaussian function?
I have a Tiff image file, on it there's an almost round spot, e.g. laser profile.
Is there a way in mathematica to 2D Gaussian fit the spot?

Szabolcs Horvát

unread,
Apr 28, 2012, 5:23:36 AM4/28/12
to
Hello,

The best way to do this would depend on the kinds of images you have
(i.e. how noisy they are, how many spots are there, etc.)

The functions here could be useful to you:

http://reference.wolfram.com/mathematica/guide/SegmentationAnalysis.html

For example ComponentMeasurements will help measure the spot and also
identify its centre. Then you could cut the spot from the image and
convert it to a matrix so you can use fitting methods such as those
implemented in NonlinearModelFit.

I recommend looking at this blog post as well:

http://blog.wolfram.com/2012/01/04/how-to-count-cells-annihilate-sailboats-and-warp-the-mona-lisa/

--
Szabolcs Horvát
Visit Mathematica.SE: http://mathematica.stackexchange.com/

Cisco Lane

unread,
Apr 30, 2012, 4:46:47 AM4/30/12
to
You might consider a polynomial fit to the logarithm of your data to the logarithm of the Gaussian, (which is a polynomial). A direct fit of the data to a Gaussian will minimize the square of the differences between the data and the Gaussian. This will tend to give large relative errors in the wings, and small relative errors in the spot. A logarithmic fit will minimize the relative errors, rather than the absolute errors. The "percent error" will be roughly the same over the entire field. I don't know if this is acceptable to you or not.

FairView

unread,
May 1, 2012, 5:23:53 AM5/1/12
to
I'm kinda new to Mathematica. My above question should be devided into
2 parts:
1) how to read data from TIFF file (i.e. read image into intensity
matrix)
2) hot to fit the retrived data to a 2D Gaussian function

0 new messages