Live data from Hacker News

Page Dewarping

mzucker.github.io

41–50 of 75 posts

Re: Page Dewarping

#41
post #32

Earlier quoted context omitted.

If she literally scans it with a scanner, why would it need dewarping? This is for when you use a digital camera on pages not lying flat. If you have the option go for scanning. Scans still benefit from cleanup, such as rotation and adjusting the levels (making everything near white perfectly white) and possibly manual cleanup (removal of specks of dust or the odd hair that was on the scanner).

She scans it in a scanner, but the music is often in large books that don't lay completely flat, so you still see the warping near the binding.

Ah that; it's a major difficulty. A problem is that not only does the shape warp, but any part of the image that is lifted away from the scanner glass, even slightly, gets blurred quite a bit.

Re: Page Dewarping

#42
post #32

Earlier quoted context omitted.

If she literally scans it with a scanner, why would it need dewarping? This is for when you use a digital camera on pages not lying flat. If you have the option go for scanning. Scans still benefit from cleanup, such as rotation and adjusting the levels (making everything near white perfectly white) and possibly manual cleanup (removal of specks of dust or the odd hair that was on the scanner).

She scans it in a scanner, but the music is often in large books that don't lay completely flat, so you still see the warping near the binding.

I built one of these, it's really simple and quick to make. http://www.instructables.com/id/Bargain-Price-Book-Scanner-F...

They still warp, but less than laying flat on the table and it's quicker if you do all the even pages, then all the odd pages. Actually the hardest part is making the camera stable so it doesn't move when you press the button.

Lots of info on different hardware setups and scanning software here that can batch translate into pdf and different formats.

http://www.diybookscanner.org/forum/index.php

Re: Page Dewarping

#43
post #32

Earlier quoted context omitted.

She scans it in a scanner, but the music is often in large books that don't lay completely flat, so you still see the warping near the binding.

I built one of these, it's really simple and quick to make. http://www.instructables.com/id/Bargain-Price-Book-Scanner-F... They still warp, but less than laying flat on the table and it's quicker if you do all the even pages, then all the odd pages. Actually the hardest part is making the camera stable so it doesn't move when you press the button. Lots of info on different hardware setups and scanning software here…

With that setup, I'd just find a sheet of glass to press the page flat. Cameras have resolution in the right ball park these days. 600 dpi across 8 inches is, what, 4800 pixels.

Re: Page Dewarping

#44

This strikes close to home for me, because I've done this "by hand" quite a number of times, using some interactive Gimp filters, with very good results. I've been able to take a perspective photo of a curved page lying on a desk, get it almost perfectly straight, and threshold it to clean black and white or sharp gray scale. Here is my very quick and dirty manual job of the same example page: http://www.kylheku.com/…

Echoing what the other comment said, blurring and setting as Divide has never occurred to me. I just tried it and it does a very good job at leveling. Nice one.

Re: Page Dewarping

#45
post #36

This strikes close to home for me, because I've done this "by hand" quite a number of times, using some interactive Gimp filters, with very good results. I've been able to take a perspective photo of a curved page lying on a desk, get it almost perfectly straight, and threshold it to clean black and white or sharp gray scale. Here is my very quick and dirty manual job of the same example page: http://www.kylheku.com/…

Divide by blur is very crafty. Will have to give that a shot next time I have a similar need in Photoshop.

As a comic artist working with scanned images, the "divide by blur" trick is going to save me significant effort in the future.

THIS is exactly the sort of insight I wish I would get when I click one of those "one weird trick" links!

Re: Page Dewarping

#46

This strikes close to home for me, because I've done this "by hand" quite a number of times, using some interactive Gimp filters, with very good results. I've been able to take a perspective photo of a curved page lying on a desk, get it almost perfectly straight, and threshold it to clean black and white or sharp gray scale. Here is my very quick and dirty manual job of the same example page: http://www.kylheku.com/…

Echoing what the other comment said, blurring and setting as Divide has never occurred to me. I just tried it and it does a very good job at leveling. Nice one.

The radius of 50 was too large. Reason being: I'm used to working with much higher resolution scans, and without high contrast shadows across them. A blur radius of around 15 does a good job of eliminating the shadow edge in this image after the divide. What we're basically doing is a high pass filter. The radius of 50 is too low a frequency; it lets through the shadow edge noticeably.

By the way, here is a useful trick: blurred layer in Divide mode, plus vary the opacity. You can reduce the amount of contrast between light and dark areas in an image without completely leveling it. Works well with low opacity levels (just a slight blend of the Divide mode layer). If you have a picture with areas that are too dark and too bright, a touch of this can help. High radii tend to work well, with blends of up to 20% or so.

For me, this does what I want Retinex to do! Only better, with intuitive control parameters and predictable results.

Re: Page Dewarping

#47
post #4

Recently, Dropbox wrote about dewarping prior to OCR in their app: https://news.ycombinator.com/item?id=12297944 This code had the same idea, and is open-source!

No, what this code does is much more sophisticated - Dropbox do not dewarp (i.e. remove non-linear distortions) they only transform the image to make the document rectilinear (leaving the distortions/deformations intact), which is much simpler.

Re: Page Dewarping

#48
How much of an effect does the camera lens make in page warping? Correct me if I'm wrong, but for shorter focal length lenses I would think it would warp the page more. If a person accounted for that, could they get a near perfect result? Or does his algorithm account for that? It seems that one would need to know where the center of the image would be.

Re: Page Dewarping

#49

Earlier quoted context omitted.

Echoing what the other comment said, blurring and setting as Divide has never occurred to me. I just tried it and it does a very good job at leveling. Nice one.

The radius of 50 was too large. Reason being: I'm used to working with much higher resolution scans, and without high contrast shadows across them. A blur radius of around 15 does a good job of eliminating the shadow edge in this image after the divide. What we're basically doing is a high pass filter. The radius of 50 is too low a frequency; it lets through the shadow edge noticeably. By the way, here is a useful tr…

Just came up with an improvement to the above: Divide by Blur, with 0-20% blend. However, not over the RGB image, but only over its its L (lightness) channel in a LAB colorspace separation. Then, recompose. That looks really natural for brightening the shadows and reducing highlights.

Look at the picture of the little girl peering out of the back window of a truck on NASA's Retinex page, as enhanced by Retinex:

http://dragon.larc.nasa.gov/retinex/pao/news/

Now my version:

http://www.kylheku.com/~kaz/nasa-image-girl-truck.png

The reflection in the glass is brought out in a less cheesy way that you might not guess is the result of processing, if you don't already know.

I did a decompose of the image to the LAB color space (Colors/Components/Decompose...). Then I used a blur radius of 200 pixels on a copy of the L layer. Put into Divide mode and blended at a bit over 30%, and recomposed from LAB back to the original RGB image.

(That's a simplification; of course I had to struggle with Gimp to preserve the ID of the L layer, which is destroyed by a straight "merge layer down" after which the recompose operation fails with an error. I in fact made two copies of the L layer, and did the processing and merge operation between those two copies. Then I did a select all to copy the resulting layer to the clipboard and pasted that into the original L layer to replace it.)

Re: Page Dewarping

#50
post #48

How much of an effect does the camera lens make in page warping? Correct me if I'm wrong, but for shorter focal length lenses I would think it would warp the page more. If a person accounted for that, could they get a near perfect result? Or does his algorithm account for that? It seems that one would need to know where the center of the image would be.

Pretty sure focal length would affect things as you say, but also physical dimensions matter too. My program assumes fixed focal length and then picks the page dimensions that work with the assumed focal length -- almost certainly not the correct ones.
Post reply on HN