Thursday, 15 August 2013

MATLAB index out of bounds error -



MATLAB index out of bounds error -

i have wrote next snippet of code however, receiving index out of bounds error. unsure how prepare this. know how can resolve it. in advance!

image = imread('image_3.jpg'); %parameters n = 100; 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:row j= 1:col-1 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 ??? attempted access cyy(1,901); index out of bounds because size(cyy)=[700,900]. error in ==> snake @ 31 eterm(i,j) = (cyy(i,(j-1)+1)*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);

change line calculate image size to:

[row col] = size(smth);

image rgb , (i presume) 700 900 3. because input has 3 dimensions , you're asking 2 outputs, multiplies lastly 2 dimensions together, giving col = 2700.

matlab

No comments:

Post a Comment