First build with automatic dewarping

Scan Tailor specific announcements, releases, workflows, tips, etc. NO FEATURE REQUESTS IN THIS FORUM, please.

Moderator: peterZ

Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: First build with automatic dewarping

Post by Tulon »

n9yty wrote:Looks like my changes to fix the crash on the Mac with zones never made it into the source repository
True. I seem to remember I was willing to accept the patch based on timings, rather than the one based on intercepting all kinds of events of QMenu. If you re-submit that patch, I may apply it.
BTW, I've recently filled the appropriate suggestion to fix or extend the QMenu API to the Qt bugtracker. Don't hold your breath though - it took them like a year to acknowledge and fix the previous bug I reported to them.
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.
Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: First build with automatic dewarping

Post by Tulon »

eL_PuSHeR wrote:I am beginning to think it's some issue in Win7.
No, I found and fixed the problem. It only happened in Color/Grayscale mode with illumination equalization turned off, which is why I couldn't reproduce it. Problems with crash reporting might well be Windows 7 related though.
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.
User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Re: First build with automatic dewarping

Post by rob »

Tulon wrote:Rob, I think RANSAC should work really well for selecting two representative lines. You basically pick two at random, build a distortion model based on them and check how well other lines fit into that model. Repeat the process a number of times and go with the best attempt. What do you think?
I didn't realize it at the time, but I used a RANSAC algorithm to choose lines for dekeystoning in my original program. It seemed to work very well, so it might be a good idea to consider.

I think what I did was generate vertical margins based on the topmost longest and bottommost longest lines, then checked all the lines to make sure that they did not go too far outside or too far inside those margins. (I emphasize too far inside because I assumed a uniform block of text) If a line did, remove it, and try again until a good fit is obtained. "Topmost" and "bottommost" didn't mean the absolute top and bottom line, but any line in the top 1/3 of the page, and any line in the bottom 1/3 of the page. The algorithm is more heuristic than anything else.

One other thing I'm considering -- a preprocessor which uses a checkerboard pattern to correct for keystoning (but not for warping). The idea would be that you could place a checkerboard on top of the platen every so often. After all your images are taken, a preprocessor program would run through the images, and if it detects a checkerboard, detect the corners of the checkerboard, compute a dekeystoning matrix, and correct any following images.

I had originally thought that the dekeystoning could be applied more smoothly by interpolating between checkerboard pages, but then I realized that any time you changed the location, orientation, or zoom of the camera, you would have to insert a checkerboard which would only be valid for the next pages, not the previous pages.

Now, OpenCV has all this code built in. And it's C. You might be able to add the OpenCV library to Scan Tailor and do this within Scan Tailor, but I could probably write a standalone program that could be run before ST, to give ST an easier time with the images.

Anyway, those are some random thoughts.
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: First build with automatic dewarping

Post by Tulon »

So, I think I've got vertical bounds detection right this time. It works well both for easy and hard cases, and I managed to avoid any heuristics.
Here is a new build: http://depositfiles.com/files/o52qhslyi
Below are some sample results.
Now I'll try to implement RANSAC for selecting the representative text lines. BTW, I've added more visualizations to the process of vertical boundaries detection, to make it easier to understand what's going on.
vertical_bounds_1.jpg
vertical_bounds_1.jpg (96.21 KiB) Viewed 8072 times
vertical_bounds_2.jpg
vertical_bounds_2.jpg (106.64 KiB) Viewed 8072 times
vertical_bounds_3.jpg
vertical_bounds_3.jpg (57.12 KiB) Viewed 8072 times
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.
User avatar
daniel_reetz
Posts: 2812
Joined: 03 Jun 2009, 13:56
E-book readers owned: Used to have a PRS-500
Number of books owned: 600
Country: United States
Contact:

Re: First build with automatic dewarping

Post by daniel_reetz »

That's great -- can't wait to try it. I've been abusing Scan Tailor with some really sub-optimal input, and still getting mostly good results, but I've had quite a few outputs like this one, where the top line is the obvious problem:
Attachments
ScanTailor.jpg
ScanTailor.jpg (81.12 KiB) Viewed 8068 times
Tulon
Posts: 687
Joined: 03 Oct 2009, 06:13
Number of books owned: 0
Location: London, UK
Contact:

Re: First build with automatic dewarping

Post by Tulon »

I'd like the source image for testing.
Scan Tailor experimental doesn't output 96 DPI images. It's just what your software shows when DPI information is missing. Usually what you get is input DPI times the resolution enhancement factor.
User avatar
daniel_reetz
Posts: 2812
Joined: 03 Jun 2009, 13:56
E-book readers owned: Used to have a PRS-500
Number of books owned: 600
Country: United States
Contact:

Re: First build with automatic dewarping

Post by daniel_reetz »

Sure. "CIMG0869" from this directory: http://www.diybookscanner.org/for_tulon/ - DPI should be 238.

I've included some others so you can see how awful this input is - it's quite literally pointing a camera at a book under mixed color temperature lighting. The book is in the public domain, so it's fine to share far and wide.

I am planning on doing some more sane testing under better controlled conditions when I get home from work tonight.
User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Re: First build with automatic dewarping

Post by rob »

That's got to be one of your water-logged books :)
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
matt

Re: First build with automatic dewarping

Post by matt »

grab 2011-01-03 at 9.12.47 AM.PNG
grab 2011-01-03 at 9.12.36 AM.PNG
grab 2011-01-03 at 9.12.16 AM.PNG
Awesome work, Tulon -- the auto-dewarping is pretty magical!

One thing I've noticed with the betas is that I have been seeing a number of cases like above (using the latest version from Git).

Thanks again for all of your work!
Attachments
original.JPG.zip
(2.08 MiB) Downloaded 381 times
matt

Re: First build with automatic dewarping

Post by matt »

Just noticed another example of distortion using beta 5.
Attachments
grab 2011-01-03 at 9.40.57 AM.PNG
distortion.zip
includes source image
(3.41 MiB) Downloaded 412 times
Post Reply