Page 2 of 2

Re: Dewarping with a regular calibration point grid

Posted: 29 Aug 2013, 22:41
by abmartin
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.

Re: Dewarping with a regular calibration point grid

Posted: 31 Aug 2013, 17:18
by mhr
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.

Re: Dewarping with a regular calibration point grid

Posted: 31 Aug 2013, 17:28
by mhr
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 504 times
ppmroselib.h.txt
Header file for library
(8.13 KiB) Downloaded 482 times
ppmroselib.cc.txt
Library file version 1.4
(19.48 KiB) Downloaded 496 times
ppmunwarp.cc.txt
Program ppmunwarp in version 1.4
(53.92 KiB) Downloaded 479 times
ppmwhitebalance.cc.txt
Program ppmwhitebalance in version 1.4
(23.06 KiB) Downloaded 484 times

Re: Dewarping with a regular calibration point grid

Posted: 04 Sep 2013, 17:14
by mhr
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 625 times

Re: Dewarping with a regular calibration point grid

Posted: 05 Sep 2013, 11:56
by dtic
Could someone post a simple instruction for compiling this in Windows (presupposing no knowledge of c++ compilers) or post a binary?

Re: Dewarping with a regular calibration point grid

Posted: 05 Sep 2013, 12:36
by mhr
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 540 times

Re: Dewarping with a regular calibration point grid

Posted: 06 Sep 2013, 16:39
by dtic
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.

Re: Dewarping with a regular calibration point grid

Posted: 06 Sep 2013, 17:02
by dtic
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?

Re: Dewarping with a regular calibration point grid

Posted: 09 Sep 2013, 03:31
by mhr
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.