MATLAB: How to detect and remove staffline using hough transform in matlab

houghimage processingImage Processing Toolbox

Were beginers in matlab we would like to use Hough Transformation in Staff detection and removal of staffline using this code
BW = edge(rotI,'canny');
[H,T,R] = hough(BW);
%imshow(H,[],'XData',T,'YData',R,...
% 'InitialMagnification','fit');
axis on, axis normal, hold on;
P = houghpeaks(H,100,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
plot(x,y,'s','color','white');
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
%figure, imshow(rotI), hold on
imshow(rotI, 'Parent', handles.blank),hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
This is the sample image:
We only need to detect all the stafflines and then remove it! thanks in advance.

Best Answer

Are you happy with the x,y coordinates that it found? If not, find a different algorithm here: http://iris.usc.edu/Vision-Notes/bibliography/char979.html#Analysis%20of%20Music,%20Musical%20Notation,%20Music%20Scores. This has been done before - no use trying to reinvent the wheel, unless all those methods are no good.