I am trying to write a function that implements imfilter function. but getting this error.
??? Subscript indices must either be real positive integers or logicals
at this point
s= size(img);
Find below the code snippet
s = size(img);
Ix = zeros(s);
Iy = zeros(s);
for i = 1:s
for j = 1:s
temp = img(i-1:i+1,j-1:j+1) .* Gx;
Ix(i,j) = sum(temp(:));
end
end
Please is there anything Im doing wrong?
EDITED CODE
s = size(img);
Ix = zeros(s);
Iy = zeros(s);
for i = 2:s(1)-1
for j = 2:s(2)-1
temp = img(i-1:i+1,j-1:j+1) .* Gx;
Ix(i,j) = sum(temp(:));
end
end