fitting a 2d gaussian using lsqcurvefit
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Below is the code i am using to fit a 2d gaussian to an image (40 *40), however whenever i run this my results a dont look quite right and b the lsqcurvefit keeps stopping prematurely any help is seriously appreciated.
ydata = y(:);
size(ydata)
[n, m] = size(y);
[X,Y]=meshgrid(1:n,1:m);
x = zeros(n*m, 2);
x(:, 1)= X(:);
x(:, 2)=Y(:);
c0 = [1, 20, 40];
options=optimset('TolX',1e-6);
fun = @(c, x) (1/(sqrt(2*pi*c(1)^2)))*exp(-((c(2)-x(:, 1)).^2 + (c(3) - x(:, 2)).^2)/2*(c(1)));
cc = lsqcurvefit(fun, c0, x, ydata, [], [], options);
Ifit = fun(cc, x);
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!