fitting a 2d gaussian using lsqcurvefit
12 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!