how to correct this error "Attempted to access thinned(0,2); index must be a positive integer or logical."
img = imread('5_1_4.jpg'); figure, imshow(img)binary_image= im2bw(img,graythresh(img));thinned=im2double(bwmorph(binary_image,'thin',Inf));for x=1:size(thinned, 2) for y=1:size(thinned,1) if (thinned(x, y) == 1) CN=(abs(thinned(x+1,y)-thinned(x+1,y-1))+ abs(thinned(x+1,y-1)-thinned(x,y-1))+ abs(thinned(x,y-1)-thinned(x-1,y-1))+ abs(thinned(x-1,y-1)-thinned(x-1,y))+ abs(thinned(x-1,y)-thinned(x-1,y+1))+ abs(thinned(x-1,y+1)-thinned(x,y+1))+ abs(thinned(x,y+1)-thinned(x+1,y+1))+ abs(thinned(x+1,y+1)-thinned(x+1,y))); CN=CN/2; end endend end
Best Answer