I have a code that removes horizontal lines in an image but the problem is that it removes some of the lines that are needed for object detection. Any ide on how to make my output "cleaner"?
here is my code:
A=imread('sheetmusic.jpg');B=rgb2gray(A);C=double(B);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
if(Gx~=0) B(i,j)=abs(Gx); end endendfigure,imshow(B); title('Sobel gradient');
and here is my input image:
and here is my output:
Best Answer