Automatic page rotation
Moderator: kcleung
Automatic page rotation
I have a scanner without this function in its twain software. Anyone experience with a program or photoshop script / plugin that aligns your score perfectly horizontal? Now I do this by placing the measure tool on a score line after which I manually rotate the page, the angle of which is automatically filled in by the measure tool. Recording these actions in a macro does not work, as the value of rotation is also stored in the macro.
-
- active poster
- Posts: 201
- Joined: Wed Aug 15, 2007 11:24 pm
Peter, I create custom droplets in Photoshop that allow me to rotate any image by an arbitrary amount. I then save that so I can access it with a single click or keystroke. Even though you have to gauge the amount of rotation by eye, you can create a droplet/macro that will convert the image, rotate by x amount, then convert back. For example, if I wanted to rotate a certain image by 1 degree counter clock, I'll record a droplet using the arbitrary rotation function and save it.
Thanks. The problem is I always turn up placing books skewed very differently on my small scanner so a fixed rotation angle won't get them right. Making a collection of macros with different angles would be an alternative, but guessing the angle by the eye for each page gives at the end (for me) probably more work than quickly placing a line with the measure tool.
As most OCR programs can do it, there's got to exist some photoshop plugin...
As most OCR programs can do it, there's got to exist some photoshop plugin...
Peter, I guess it depends the margin of rotation skew on your images. Mine usually never go beyond 2 degrees, so I usually have macros from 0.5 degrees up to 1.5 degrees. These macros make quick work of each image as I can usually get the image at the correct adjustment within 0.2 degrees. Another thing that may be worth mentioning if you're concerned about printing: Acrobat reader and professional both have skew adjustments when printing, which can correct some really bad rotations in my experience, even a slight amount left over after manual rotation.
-
- Site Admin
- Posts: 2249
- Joined: Sun Dec 10, 2006 11:18 pm
- notabot: 42
- notabot2: Human
- Contact:
One of the things you will run into with printed scores, especially ones that have been reissued many times over, is the absolutely horrendous practice of some publishers or printers who simply take a bound copy from the previous run and place it beneath the printer camera. (They can sell that copy after the picture has been taken and the new "plates" burned!)
This results in a characteristic curvature found on the right end of even-numbered pages and the left end of odd-numbered ones. Repeat the process a few times, add some skewing generated by scanning and...voila! You end up with quite a fun-house mirror image of a music score. Recent Hal Leonard printings of the Mozart Requiem vocal score (itself a reprint of the Peters vocal score form ca.1880) are really quite remarkable in this regard. One could easily spend 2-3 hours per page in Photoshop fixing such atrocities. It's not worth the effort. GI/GO.
Lesson: Try to find a decent printing to start with. Not always easy to do, but it definitely improves the quality of the final product.
This results in a characteristic curvature found on the right end of even-numbered pages and the left end of odd-numbered ones. Repeat the process a few times, add some skewing generated by scanning and...voila! You end up with quite a fun-house mirror image of a music score. Recent Hal Leonard printings of the Mozart Requiem vocal score (itself a reprint of the Peters vocal score form ca.1880) are really quite remarkable in this regard. One could easily spend 2-3 hours per page in Photoshop fixing such atrocities. It's not worth the effort. GI/GO.
Lesson: Try to find a decent printing to start with. Not always easy to do, but it definitely improves the quality of the final product.
-
- active poster
- Posts: 293
- Joined: Sun Apr 23, 2006 5:08 am
- notabot: YES
- notabot2: Bot
- Location: Phoenix, AZ
I've been messing with this lately. Here are some things I've found:
Gimp plugin: http://www.cubewano.org/gimp-deskew-plugin/
I've been using this recently and it works quite well.
Unpaper: http://unpaper.berlios.de/
I haven't totally figured out how to make this work. Besides deskewing, it does some other nice things to clean up the image (remove noise pixels, black border, etc.) Unfortunately with one of my tests I couldn't get it to correctly rotate the page (though it did do some good clean up to the page), and with another test it didn't correctly convert grayscale to black and white. I still need to mess with it some more.
The technical term for what Carolus was referring to is 'dewarping'. There are some good algorithms for fixing it, but I don't know of any readymade plugins. Most are also targeted towards text documents so I'm not sure how well music will fare. Here's an online example program: http://quito.informatik.uni-kl.de/dewarp/dewarp.php.
Gimp plugin: http://www.cubewano.org/gimp-deskew-plugin/
I've been using this recently and it works quite well.
Unpaper: http://unpaper.berlios.de/
I haven't totally figured out how to make this work. Besides deskewing, it does some other nice things to clean up the image (remove noise pixels, black border, etc.) Unfortunately with one of my tests I couldn't get it to correctly rotate the page (though it did do some good clean up to the page), and with another test it didn't correctly convert grayscale to black and white. I still need to mess with it some more.
The technical term for what Carolus was referring to is 'dewarping'. There are some good algorithms for fixing it, but I don't know of any readymade plugins. Most are also targeted towards text documents so I'm not sure how well music will fare. Here's an online example program: http://quito.informatik.uni-kl.de/dewarp/dewarp.php.
-
- active poster
- Posts: 293
- Joined: Sun Apr 23, 2006 5:08 am
- notabot: YES
- notabot2: Bot
- Location: Phoenix, AZ
Here's one I just built: http://horndude77.googlepages.com/unpaper.exe
I'll take this down in the next day or so. I haven't tested it beyond 'unpaper --version'.
I built with mingw:
https://sourceforge.net/project/showfil ... _id=240780
Once mingw was installed I ran this from the src directory:
>gcc unpaper.c -o unpaper.exe -I "C:\mingw\include" -L "c:\mingw\lib"
If you figure out some good options let us know.
I heard about the tool reading over at the distributed proofreaders forum: http://www.pgdp.net/phpBB2/viewtopic.php?t=18964
I'll take this down in the next day or so. I haven't tested it beyond 'unpaper --version'.
I built with mingw:
https://sourceforge.net/project/showfil ... _id=240780
Once mingw was installed I ran this from the src directory:
>gcc unpaper.c -o unpaper.exe -I "C:\mingw\include" -L "c:\mingw\lib"
If you figure out some good options let us know.
I heard about the tool reading over at the distributed proofreaders forum: http://www.pgdp.net/phpBB2/viewtopic.php?t=18964
For some reason my MinGW is acting sick. I also tried working with gscan2pdf as a frontend, which may prove useful, but I couldn't get latest version compiled. Ubuntu package manager only had .21 I think, and even then unpaper refused to process my one test image.
When using this win32 bin I get the same error as in *nix:
"input file format using magic 'II' unknown
When using this win32 bin I get the same error as in *nix:
"input file format using magic 'II' unknown
-
- active poster
- Posts: 293
- Joined: Sun Apr 23, 2006 5:08 am
- notabot: YES
- notabot2: Bot
- Location: Phoenix, AZ
Yeah I figured that out after I posted it and have been playing with it. I'm having difficulties with the masks obliterating my instrument abbreviations sometimes, and others pages that were somewhat straight now skewed. I contacted the author but haven't heard anything back yet. I'm not sure how to configure it best for music and was hoping for his input. When it works it does a really nice job. I just need to figure out how I can write back the dpi info. in a batch convert from PBM->TIFF.
-
- active poster
- Posts: 293
- Joined: Sun Apr 23, 2006 5:08 am
- notabot: YES
- notabot2: Bot
- Location: Phoenix, AZ
Something like this should do the trick (using imagemagick and bash):
Code: Select all
#!/bin/bash
for i in *.pbm
do
convert -density 600 -units PixelsPerInch $i ${i%.*}.tiff
done