How to fit a Gaussian curve to the profile obtained from "improfile"?

15 views (last 30 days)
Hi,
I have generated an intensity profile across a line section for my image using improfile. How do I get MATLAB to fit a Gaussian curve to this "noisy" profile?
The main aim is to fit a 2D Gaussian to the pixel values at each position across a 2D image, and to display the result visually in real time.
If this is not possible, then please advise me on other methods.
Thank you!

Answers (1)

Bruno Pop-Stefanov
Bruno Pop-Stefanov on 22 Jan 2014
Edited: Bruno Pop-Stefanov on 22 Jan 2014
You can fit a mixture of Gaussian models to your profile interactively using the Curve Fitting Toolbox. Here is a tutorial:
Execute cftool to open the Curve Fitting tool. Select your profile as y-data then select "Gaussian" in the model list. You can visualize the profile and see how changing the number of Gaussian models affects the fit.
I suggest you blur your profile to smooth it before trying to fit a Gaussian to it. Use fspecial to create a filter and imfilter to blur the profile:
h = fspecial('gaussian', [1 7]);
smooth_profile = imfilter(profile, h, 'replicate');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!