Getting the most out of your inverted-platen scanner
Things you will need:
- ImageMagick
- Some program that will let you pick out coordinates of points on your image. Photoshop does it, but I'm not sure what else does.
- Scan Tailor or BookScanWizard
One of the advantages of an inverted-platen scanner is that the platen does not move relative to the camera. This means you can take all of your pictures, and as long as the camera doesn't change location or orientation, the same exact keystoning will happen to every image. Also, the spine of the book will be (approximately) in the same position in every image. This lets you do some very simple yet powerful image cleanup before turning Scan Tailor or BookScanWizard loose on your images.
Here's a sample image.
The first step will be to rotate and dekeystone the image all at once. Select an image that has a full page of text. Determine the coordinates of the points at either end of the topmost and bottommost full line. Use the bottoms of the lines rather than the tops. Write down the coordinates. Making a little diagram helps.
- scan-2.jpg (111.06 KiB) Viewed 13003 times
While you're at it, calculate the long and short sides of your text block using the good ol' Pythagorean Theorem. My sample image has a long side of 1854 and a short side of 1199. The particular side you measure doesn't matter much. Also, take a ruler and measure one of the sides. Divide the number of pixels by the measured size, and you get the dpi of the image. Notice that my dpi ended up being 353, which is really not too bad!
Now, here's what you want to end up with:
So we have four source points and four destination points. Let's label the destination points UL, UR, LL, and LR (upper left, upper right, lower left, and lower right). Let's also label the source points ULs, URs, LLs, and LRs -- but ULs is not the upper left of the
image but of the
page. Thus, in the example above,
ULs = 2388, 500
URs = 2432, 1712
LLs = 536, 578
LRs = 582, 1776
The question is, what should UL, UR, LL, and LR be? First, let's set UL = LLs. Why? Because this is the source point with the lowest x and y coordinates. Note that if your image is of the opposite page, you will probably end up setting UL = URs.
UL = 536, 578
Now it is just a matter of adding the short side pixel distance to x:
UR = 1735, 578
And then adding the long side pixel distance to y:
LL = 536, 2432
LR = 1735, 2432
Now we will use ImageMagick to map ULs -> UL, URs -> UR, LLs -> LL, and LRs -> LR. Do the one image you picked out first, as follows:
Code: Select all
convert input.jpg -virtual-pixel black +distort Perspective "ULs,UL URs,UR LLs,LL LRs,LR" +repage -density dpixdpi output.jpg
For my page, this command line looks like this:
Code: Select all
convert IMG_0006.JPG -virtual-pixel black +distort Perspective "2388,500,536,578 2432,1712,1735,578 536,578,536,2432 582,1776,1735,2432" +repage -density 353x353 output.jpg
And the result:
- scan-4.jpg (105.32 KiB) Viewed 13003 times
I've taken the liberty of drawing a line right around the middle of the platen bend. Measure this using the coordinate measuring program. Mine came out to (about) 528. Exactness isn't quite necessary, but you might err on the side of caution, because we're going to use ImageMagick again to get rid of the opposite partial page:
Code: Select all
convert output.jpg -crop +528+0 +repage output2.jpg
The above removes stuff on the left. To remove stuff on the
right starting from X, use this instead:
Code: Select all
convert output.jpg -crop Xx0+0+0 +repage output2.jpg
- scan-5.jpg (119.53 KiB) Viewed 13003 times
There! Now we have a nice single page. This makes it easier for Scan Tailor and BSW to deal with.
Next, delete output.jpg and output2.jpg. Create a directory called, say, "fixed_images". Now, if you're on OSX or Linux, running the command on every image is easy:
Code: Select all
for i in *.JPG
do
convert $i -virtual-pixel black +distort Perspective "2388,500,536,578 2432,1712,1735,578 536,578,536,2432 582,1776,1735,2432" +repage -density 353x353 -crop +528+0 +repage fixed_images/$i
echo $i
done
In Windows, it's a little more weird (and this may not work, since I don't use Windows):
Code: Select all
FOR %%i IN (*.JPG) DO 'convert %%i -virtual-pixel black +distort Perspective "2388,500,536,578 2432,1712,1735,578 536,578,536,2432 582,1776,1735,2432" +repage -density 353x353 -crop +528+0 +repage fixed_images/%%i'
If it doesn't work, ask on the forum for anyone who can get it to work. Or download and install
Cygwin, which will let you run Unix-type commands on Windows. Then you can use the OSX/Linux commands above.
Anyway, your resulting images are now in fixed_images. Do the whole thing again for the images from your other camera (measure, dekeystone, crop), and point ST or BSW at your resulting images. After ST or BSW finishes up with the images, they are nice and clean:
- scan-6.jpg (177.62 KiB) Viewed 13003 times
Anyway, that's it. Good luck, and have fun scanning!