Hey there,
I'm trying to figure out how to detect and classify music notes from a scan of music sheet.
My source picture is following:
As it is shown in the example found on the forum, (How to extract lines from music sheet), I tried to remove staff lines from the picture. My result is looks like that:
Problems that I am struggling with are:
First of all, in the example linked above, the staff lines are extracted from the image, not removed. Should I apply subtraction to remove extracted lines? My result was obtained after erosion and two dilation operations with changed parameters of Horizontal Structure
/Horizontal lines removal/ //int horizontalsize = imgHThreshCopy.cols / 10; // Specify size on horizontal axis Mat horizontalStructure = getStructuringElement(MORPH_RECT, Size(1, 3)); Mat horizontalStructure3 = getStructuringElement(MORPH_RECT, Size(2, 1)); Mat horizontalStructure2 = getStructuringElement(MORPH_ELLIPSE, Size(2,2)); // Create structure element for extracting horizontal lines through morphology operations erode(imgHThreshCopy, imgHThreshCopy, horizontalStructure, Point(-1, -1), 3); // Apply morphology operations dilate(imgHThreshCopy, imgHThreshCopy, horizontalStructure2, Point(-1, -1), 2); dilate(imgHThreshCopy, imgHThreshCopy, horizontalStructure3, Point(-1, -1), 4);
However, such approach removes also some part of half note on its upper and lower egde, creating a hole. Maybe I don't get the example properly? Why do they apply verical morphology as well, if they are extracting staff lines only?
If I've got such result, how can I detect if the note is quarter or half? If the contour is not closed because of the horizontal lines removal, I don't know how to classify it.
Is it necessary to remove stems? I tried also vertical erosion followed by dilation operation, but it is destoying half-notes even more.
This task is my first one to complete using OpenCV and c++ programming, so I would be grateful for all hints and explenations :)