matlab - Subscript indices must either be real positive integers or logicals Error + Code -
i wondering if can explain me error means. and, if possible, how resolve it? ??? subscript indices must either real positive integers or logicals.
error in ==> interp2>linear @ 344 f = ( arg3(ndx).*(onemt) + arg3(ndx+1).*t ).*(1-s) + ... error in ==> interp2 @ 220 zi = linear(extrapval,x,y,z,xi,yi); error in ==> snake @ 71 ssx = gamma*xs - kappa*interp2(fx,xs,ys);
this finish code:
image = imread('image.jpg'); %parameters alpha = 0.001; beta = 0.4; kappa=0.0001; gamma = 100; n = 100; wl = 10; = 10; wt = 10; smth = rgb2gray(image); % calculating size of image [row col] = size(image) eline = smth; %eline image intensities [grady,gradx] = gradient(double(smth)); eedge = -1 * sqrt ((gradx .* gradx + grady .* grady)); %eedge measured gradient in image m1 = [-1 1]; m2 = [-1;1]; m3 = [1 -2 1]; m4 = [1;-2;1]; m5 = [1 -1;-1 1]; cx = conv2(smth,m1,'same'); cy = conv2(smth,m2,'same'); cxx = conv2(smth,m3,'same'); cyy = conv2(smth,m4,'same'); cxy = conv2(smth,m5,'same'); = 1:700 j= 1:900 % eterm deined in kass et al snakes paper eterm(i,j) = (cyy(i,j)*cx(i,j)*cx(i,j) -2 *cxy(i,j)*cx(i,j)*cy(i,j) + cxx(i,j)*cy(i,j)*cy(i,j))/((1+cx(i,j)*cx(i,j) + cy(i,j)*cy(i,j))^1.5); end end eext = (double(wl.*eline) + double(we.*eedge -wt) .* eterm); %eext weighted sum of eline, eedge , eterm [fx, fy] = gradient(eext); %computing gradient xs=1:900; xs=xs'; ys=repmat(242,1,900); ys=ys' [m n] = size(xs); [mm nn] = size(fx); %populating penta diagonal matrix = zeros(m,m); b = [(2*alpha + 6 *beta) -(alpha + 4*beta) beta]; brow = zeros(1,m); brow(1,1:3) = brow(1,1:3) + b; brow(1,m-1:m) = brow(1,m-1:m) + [beta -(alpha + 4*beta)]; % populating template row i=1:m a(i,:) = brow; brow = circshift(brow',1)'; % template row beingness rotated egenrate different rows in pentadiagonal matrix end [l u] = lu(a + gamma .* eye(m,m)); ainv = inv(u) * inv(l); % computing ainv using lu factorization %moving snake in each iteration i=1:n; ssx = gamma * xs - kappa * interp2(fx,xs,ys); %this receive error ssy = gamma * ys - kappa * interp2(fy,xs,ys); %calculating new position of snake xs = ainv * ssx; ys = ainv * ssy; %displaying snake in new position % imshow(image,[]); % hold on; plot([xs; xs(1)], [ys; ys(1)], 'r-'); % hold off; % pause(0.001) end;
sounds trying access position 0 or non-integer (0.1) of array, matlab arrays start @ position 1.
>> a=[1,2,3]; >> a(0) ??? subscript indices must either real positive integers or logicals. >> a(1) ans = 1
matlab
No comments:
Post a Comment