Scanned piano sheets enhancement

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Toshico
Posts: 1
Joined: 2019-03-21T11:16:31-07:00
Authentication code: 1152

Scanned piano sheets enhancement

Post by Toshico »

Hello dear image processing community :D

I have a little challenge for you : I have a lot of scanned piano sheet.
As you could guess, books are not very practical when playing piano. (doesn't stay open damn 200 pages book !)
That's why scanning is very important because it allows to use the sheets with a Windows Surface or an iPad directly or reprint them on single pages.

Anyway, the problem is the readability of such scans.
I have tons of scans that looks like that :
Image
Bright scan

Image
Dark scan

So, I'm trying to batch process all the scan that I have in order to improve them (and pack them into pdfs but that's another story and I'm okay with this part).
In order to achieve that, I need a single script that would be able to improve any music sheet.

So far, I tried some command that I found here and there but with no real improvement.

Code: Select all

convert in.jpg       -negate -lat 50x50+1% -negate     out1.jpg
convert in.jpg                                         out2.jpg
mogrify              -normalize                        out2.jpg
convert in.jpg       -auto-level					   out3.jpg
convert in.jpg 		 -despeckle -despeckle 			   out4.jpg
I was thinking about doing those steps :
1) auto-level in order to accentuate the difference between bright and dark part of the document
2) make the 60% brightest pixels white (because they should represent the background)
3) make the 10% darkest pixels black (because they should represent the music notation)
4) make the 30% remaining pixels from white to black (because the should represent the blur effect that makes the sheet readable)

But I don't know how to do that or if it would work. I think the steps 2), 3) and 4) could be done with Sigmoidal Non-linearity Contrast but I must admit that I am lost.

Do you know how I could achieve what I want ? Is my approach valid ? Is there another way to get the results I would like ?


Thank you very much for your help. I'll keep you inform if I find something interesting ;)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scanned piano sheets enhancement

Post by snibgo »

"-contrast-stretch 10x60%" does your steps 2, 3 and 4. Step 1 isn't needed.

However, your input is weird. It has essentially four shades of gray. I suspect it has been processed somehow. Use a better scan, if you can.
snibgo's IM pages: im.snibgo.com
Post Reply