I wrote this Code fragment

E note

Which is a E (quarter) note in Treble Clef. Instead Mathematica simply classified it as a "musical note" Can we do better?

  • 4
    $\begingroup$ I’m sure one could, with some effort. I wanted to point out this though: you have to your credit 19 questions that have received answers, some heavily upvoted, and yet you accepted only 4 of those. Accepting valuable answers that solve your problem in due time is good form on this forum. Consider doing some of that. $\endgroup$
    – MarcoB
    Apr 25, 2020 at 16:29
  • $\begingroup$ Sorry, I will do that now. Been lazy I guess. But here is a blanket upvote to all those who took the time to answer my questions.. $\endgroup$ Apr 25, 2020 at 16:55
  • $\begingroup$ There are four musical clefs that come in various key indications; none of which are indicated in the image. With out this information all anyone (including ImageIdentify) can do is identify it as a musical note. I look at it in the context of a bass clef and see either a low G, G-sharp, or G-flat. $\endgroup$
    – Edmund
    Jun 4, 2020 at 12:13
  • $\begingroup$ Assume some such qualifier is provided. Assume its all Treble clef.. $\endgroup$ Jun 5, 2020 at 15:25

1 Answer 1


Here is my humble approach.

sheet = Import["https://rmurta.s3-sa-east-1.amazonaws.com/mathematica-playground/sheet.png"];
note = Import["https://rmurta.s3-sa-east-1.amazonaws.com/mathematica-playground/note.png"];

examples = Map[ImageResize[#, 100]&]/@ <|
"mi" -> (ImageCompose[sheet, note,{200,235} + #]&/@RandomReal[{-5,5},{4,2}]),
"fa" -> (ImageCompose[sheet, note,{200,280} + #]&/@RandomReal[{-5,5},{4,2}]),
"sol" ->(ImageCompose[sheet, note,{200,360} + #]&/@RandomReal[{-5,5},{4,2}]),
"la" ->(ImageCompose[sheet, note,{200,400} + #]&/@RandomReal[{-5,5},{4,2}]),
"si" ->(ImageCompose[sheet, note,{200,430} + #]&/@RandomReal[{-5,5},{4,2}]),
"do" ->(ImageCompose[sheet, note,{200,490} + #]&/@RandomReal[{-5,5},{4,2}])

c = Classify[examples];

Copying your example into Mathematica, and applying c into It:

enter image description here

  • $\begingroup$ Thanks but did not work for any other notes.. $\endgroup$ May 5, 2020 at 7:32
  • $\begingroup$ Can you please send me the images of list of notes you have that worked for you.. $\endgroup$ May 5, 2020 at 14:56
  • $\begingroup$ Just execute: ImageCompose[sheet, note,{200,360}] $\endgroup$
    – Murta
    May 5, 2020 at 15:38
  • $\begingroup$ I thought as much. This is unrelated to Machine Learning. For example, it does not work for handwritten notes. I wanted a machine-learning algorithm that can identify notes the way a human would. $\endgroup$ May 6, 2020 at 8:30
  • $\begingroup$ I want to use commands like ImageIdentify that are machine learning related. $\endgroup$ May 6, 2020 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.