I believe there is a bug in the line 81, should be
I_internal = I([ones(1,ceil((regsize(1)-1)/2)) 1:end size(I,1)*ones(1,(regsize(1)-1)/2)],...
[ones(1,ceil((regsize(2)-1)/2)) 1:end size(I,2)*ones(1,(regsize(2)-1)/2)]);
hi
im working on grading of food grains using image processing technique, for which i m using edge detetction technique n i'll find perimeter after that i'll provide grading of each sample.