Daniel Reetz, the founder of the DIY Book Scanner community, has recently started making videos of prototyping and shop tips. If you are tinkering with a book scanner (or any other project) in your home shop, these tips will come in handy. https://www.youtube.com/channel/UCn0gq8 ... g_8K1nfInQ

Dewarping with a regular calibration point grid

Share your software workflow. Write up your tips and tricks on how to scan, digitize, OCR, and bind ebooks.
abmartin
Posts: 79
Joined: 15 Sep 2010, 15:33
Number of books owned: 2000
Country: USA
Location: Ohio

Re: Dewarping with a regular calibration point grid

Post by abmartin » 29 Aug 2013, 22:41

mhr,

Thanks again for writing this great tool! Adding the 16 bit ppm capability is a nice addition. That should make some of the RAW stuff easier. Thanks also for giving us another option for automatically determining DPI. Royeven's method seems to be pretty accurate in my tests, but I'm very interested to try your approach too! I'll have to update my scripts again to add that new option for DPI calculation.

Thanks for making it so flexible. I can't see a scenario where we might need x and y dpi to be different, but it's great that it's there for the future when someone figures out a practical usage scenario.

You mentioned awhile back that you were considering buiding a curved scanning rig. How did that work for you? It's an interesting idea.

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: Dewarping with a regular calibration point grid

Post by mhr » 31 Aug 2013, 17:18

Hello abmartin,

nice to see that my program is useful for You!
Actually I discarded the idea of a curved scanning rig a while ago.
It was based on an erroneous idea about depth of field.
So I use a flat platen as all others also do.
I have a one camera setup with fixed geometry between camera and platen.
I might show my scanner in the buildt thread in the future if I have some spare time for that,
but it is based on different ideas already presented there.

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: Dewarping with a regular calibration point grid

Post by mhr » 31 Aug 2013, 17:28

I splitted the identical parts of the programs ppmunwarp and ppmwhitebalancing into a library
and eliminated a bug in ppmunwarp due to regression (version 1.0 was not affected).
Here are both programs in version 1.4 together with the library and a primitive makefile. Just drop the .txt ending as always to compile. For use of ppmwhitebalance see thread
http://www.diybookscanner.org/forum/vie ... =19&t=2891.
Makefile.txt
Makefile for version 1.4 of ppmunwarp und ppmwhitebalance
(442 Bytes) Downloaded 191 times
ppmroselib.h.txt
Header file for library
(8.13 KiB) Downloaded 179 times
ppmroselib.cc.txt
Library file version 1.4
(19.48 KiB) Downloaded 188 times
ppmunwarp.cc.txt
Program ppmunwarp in version 1.4
(53.92 KiB) Downloaded 182 times
ppmwhitebalance.cc.txt
Program ppmwhitebalance in version 1.4
(23.06 KiB) Downloaded 184 times

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: Dewarping with a regular calibration point grid

Post by mhr » 04 Sep 2013, 17:14

Hier is version 1.5 of the programs.
ppmwhitebalance was enhanced to accept a rectangle
by using the new options -gx, -gy, -gw and -gh.
The rectangle should roughly specify the area of the gray card in the picture.
Outside the rectange, the gray card pixels are set to the mean color value from the rectangle.
This relaxes unwanted border effects somewhat.
If an additional percentage value is given by the new option -go, then all pixels whose color
differs by more then the specified percentage from the mean value are also set to the mean value.
This can reduce the unwanted effects due to paper clips holding the gray card.
ppmrose_v1.5.zip
Version 1.5 of the programs ppmunwarp and ppmwhitebalance
(32.29 KiB) Downloaded 260 times

dtic
Posts: 441
Joined: 06 Mar 2010, 18:03

Re: Dewarping with a regular calibration point grid

Post by dtic » 05 Sep 2013, 11:56

Could someone post a simple instruction for compiling this in Windows (presupposing no knowledge of c++ compilers) or post a binary?

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: Dewarping with a regular calibration point grid

Post by mhr » 05 Sep 2013, 12:36

In Microsoft Visual Studio there is a Batchfile called 'vcvarsall.bat'
This can be called within a console 'cmd.exe' to set up all variables to compile on the command line.
The files can be compiled with a command like

Code: Select all

cl /Ox ppmunwarp.cc ppmroselib.cc
cl /Ox ppmwhitebalance.cc ppmroselib.cc
Anyway, here are the 64bit executables (compiled under Windows 7, Visual Studio 10):
ppmrose_v1.5_win64.zip
Compiled Binaries for Windows 64bit of
version 1.5 of ppmunwarp and ppmwhitebalance
(130.58 KiB) Downloaded 228 times

dtic
Posts: 441
Joined: 06 Mar 2010, 18:03

Re: Dewarping with a regular calibration point grid

Post by dtic » 06 Sep 2013, 16:39

Thanks. I didn't get your vcvarsall.bat instruction at first so here are a few more details just in case anyone else comes along and stumbles at the same stage as I did.

1. Download Visual Studio Express 2012 for Windows Desktop and install.
2. Open a command prompt.
3. First send this command to set things up for compiling into x64 files

Code: Select all

call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64
4. navigate the command prompt to whatever folder you have the source files in. For example C:\stuff

Code: Select all

cd C:\stuff
5. Then send one of these commands

Code: Select all

cl /Ox ppmunwarp.cc ppmroselib.cc
cl /Ox ppmwhitebalance.cc ppmroselib.cc
which outputs ppmunwarp.exe in the same folder as the ppmunwarp.cc files, and so on.

If you close the command prompt window you need to redo step 3 again.

dtic
Posts: 441
Joined: 06 Mar 2010, 18:03

Re: Dewarping with a regular calibration point grid

Post by dtic » 06 Sep 2013, 17:02

Can you say a bit more about the gray card. Does it require a special purchased gray card? Or would any uniformly gray paper sheet do?

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: Dewarping with a regular calibration point grid

Post by mhr » 09 Sep 2013, 03:31

Just homogene gray is fine.
The gray card should fill the whole area of interest (and a bit more).
If the options -nx and -ny are specified, a local varying correction based on a gray color grid of the
calibration input is used to correct spatially varying color (e.g. due to uneven lighting conditions).
You can now specify a rectangular window (-gx, -gy, -gw, -gh) if the gray card is only part of the image.

This tool is not really needed for BW scanning (with scantailor).
But for gray shades or color images it might be useful.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest