Hi, I am trying to execute an image processing project with sobel edge detection technique. I want to write a function edgy that takes an orginal input image and process an output image. Both the input and output are grayscales images which means they are matrices of date structure unint8 values. However, whenever i run the code given below by calling the function edgy to give output edg as given in the code below, the fucntion call returns errors. Please what is the problem with the code? Any advice on the bug in this code is appreicated. Thank you
function edg=edgy(A)
C=double(A);
B=uint8(C)
edg=imshow(B)
[i,j]=size(C)
for i=1:size(C,1)-2
for j=1:size(C,2)-2
%Sobel mask for x-direction:
Gx=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2)));
%Sobel mask for y-direction:
Gy=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));
%The gradient of the image
%B(i,j)=abs(Gx)+abs(Gy);
C(i,j)=sqrt(Gx.^2+Gy.^2);
end
end
Best Answer