Find notes into a stave
4 views (last 30 days)
Show older comments
Hello everyone. I need some help with a program which consist in detect and extract notes into a stave ONE BY ONE. All the notes are simply notes (Quarter Note,Half Note,Whole Note,Eighth Note,Sixteenth Note). I need to detect the possition x,y, and count every note in the stave.I only need to know the position of the head of every note... The stave is a controlled stave, with the same dimmension and the position of the lines are always the same, no rotation, no distorsion... Could anyone help me please, or give me some ideas?
0 Comments
Answers (2)
Matt J
on 24 Dec 2013
I would try to remove the staff, leaving only the notes behind. Then I would analyze their shape and location with regionprops(). For example, below is a crude binary image of a staff with a quarter note. I can produce an image B with the staff lines removed by looking at the local thickness of the black regions and checking if that thickness is more than the thickness of a staff line,
lthick=conv2(A,[1;1;1],'same'); %local thicknesses
mask=imdilate((lthick==1)&A,[1;1;1]);
B=A&~(mask),
A =
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 1 1 1 0 0 0 0
1 1 1 1 1 1 1 1 1 1
0 0 0 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
Image Analyst
on 24 Dec 2013
People have written papers on this so I'm not going to spend time redeveloping an existing algorithm for you. Go here http://iris.usc.edu/Vision-Notes/bibliography/other1021.html#Music to find successful algorithms that people have developed and published and are using.
2 Comments
Image Analyst
on 27 Dec 2013
Alberto, if you visit here much, you'll see that I very very frequently develop custom algorithms for people and post the code. But in those cases, it's usually for something very simple that I don't have to spend more than a few minutes developing, or for demos that I already have saved on hand. Yours did not look like it fell into those categories so I wanted to point you to some places where you could find your answer, rather than wait for me to do it (like so many do). Whatever I would do in a few minutes would undoubtedly not be as good as the published methods. I thought you might like a good robust method rather than some prototype small snippet of code I hacked out in a few minutes so I thought I'd let you know where you can find them. Many people are not aware of this valuable database where virtually all image processing articles are archived . Good luck with it.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!