How to applied 2d gaussian function
Show older comments
Hi,
I tried to modifed and applied this function: https://au.mathworks.com/matlabcentral/fileexchange/55033-fit-1d-and-2d-gaussian-to-noisy-data?s_tid=prof_contriblnk by @Manuel A. Diaz
I upload my code and data I don't know why the fit not working and the amplitude not in the center of the gaussain
I hope someone can help.
Thanks,
Answers (2)
You could try this alternative gaussian fitting routine, and see if you get different results:
4 Comments
Z998567
on 3 Aug 2021
Here's what I get,
load gauss
[X,Y]=ndgrid(1:length(imageData));
XY=[X(:),Y(:)];
params=gaussfitn(XY, imageData(:));
[D,A,mu,sig]=deal(params{:});
Zfit= D + A*exp( -0.5 * sum( (sig\(XY.'-mu)).*(XY.'-mu) ));
imageFit=reshape(Zfit,size(imageData));
montage({imageData,imageFit})
caxis(4000*[0.7615 0.8126])
Z998567
on 3 Aug 2021
Matt J
on 3 Aug 2021
Once you have the fitted parameters, you can plot it any way you wish.
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
