Examples from my postprocessor software

Share your software workflow. Write up your tips and tricks on how to scan, digitize, OCR, and bind ebooks.

Re: Examples from my postprocessor software

Postby rob » 07 Jun 2009, 18:29

daniel_reetz wrote:To what degree is your processing resolution-independent? Don't you have to choose a radius for erosion and dilation to work?


Oh, I have no idea! :) For the morphological operations, you use a SEL -- a structuring element -- which has a width and a height, not a radius. I used SELs suggested by the Leptonica routines, which seem to give good results. The main purpose of the morphological operations is to denoise, which is probably not dependent on resolution, but the step where I blockify text probably is. The SEL for that is 25x1 which, if I have my morphology correct, will generally connect text horizontally as long as the dots are within 25 pixels of each other. At a ppi of 280 or so (vaguely corresponding to a nearly full page of text in the image), 25 pixels is about 6.4 points (i.e. 6.4/72 inches).

Font size is related more to height than width, so let's just suppose that any text font under about 14 points or so will be blockified.

Really, we're not dealing with mathematical truth here, just heuristics.
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
User avatar
rob
 
Posts: 770
Joined: 03 Jun 2009, 13:50
Location: Maryland, United States

Re: Examples from my postprocessor software

Postby Cabe » 08 Jun 2009, 08:13

FWIW EV stands for Exposure Value and 1 "stop" of EV is equivalent to 1 "f-stops" of true exposure. It's basically a representation of shutter and aperture for a given exposure. More EV = More Exposure = Brighter image.
Cabe
 
Posts: 34
Joined: 07 Jun 2009, 15:47
Location: Portsmouth, UK

Re: Examples from my postprocessor software

Postby jrichards » 08 Jun 2009, 08:50

Are going to allow this software to be downloaded?
jrichards
 
Posts: 22
Joined: 08 Jun 2009, 00:38
Location: Provo, Utah

Re: Examples from my postprocessor software

Postby spamsickle » 08 Jun 2009, 09:50

Cabe wrote:FWIW EV stands for Exposure Value and 1 "stop" of EV is equivalent to 1 "f-stops" of true exposure. It's basically a representation of shutter and aperture for a given exposure. More EV = More Exposure = Brighter image.

Thanks. It's funny, I used to be a serious 35 mm photographer, but I always used "daylight" film even indoors because I liked the warm colors. Never used white balance on my new digital cameras, or EV either, until this project. Still learning a lot.

Also, I don't know if it was Daniel or bkrpr who wrote that the tripod mount in these cameras takes 1/4" 20-thread bolts. That's been a lifesaver for me too, because I have three tripods and only one "quick-release" plate, and it's virtually impossible to find replacements that fit. Now, a 2" bolt and a wingnut, and I'm back to being able to use all three tripods again.
spamsickle
 
Posts: 577
Joined: 06 Jun 2009, 23:57

Re: Examples from my postprocessor software

Postby rob » 08 Jun 2009, 10:03

jrichards wrote:Are going to allow this software to be downloaded?


Yes, soon. The Java part is independent of operating system, but the Leptonica library and the Java interface to that library isn't. I develop on an Intel Mac, so I need to get three releases: Intel Mac, PowerPC Mac, and Windows.
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
User avatar
rob
 
Posts: 770
Joined: 03 Jun 2009, 13:50
Location: Maryland, United States

Re: Examples from my postprocessor software

Postby daniel_reetz » 08 Jun 2009, 11:06

I don't know if it was Daniel or bkrpr

Actually, I think we've both said it at one time or another. I mentioned it here: http://www.instructables.com/id/SWV8JKCFTM72X5S/ and in the comments somewhere. One funny thing is that all cameras worldwide use this standard, but while in Russia, I discovered that it's nigh impossible to get non-metric bolts. My first "care package" was an assortment of 1/4 20 hardware. :)
User avatar
daniel_reetz
 
Posts: 2490
Joined: 03 Jun 2009, 13:56

Re: Examples from my postprocessor software

Postby jrichards » 08 Jun 2009, 12:38

rob wrote:
jrichards wrote:Are going to allow this software to be downloaded?


Yes, soon. The Java part is independent of operating system, but the Leptonica library and the Java interface to that library isn't. I develop on an Intel Mac, so I need to get three releases: Intel Mac, PowerPC Mac, and Windows.



I am on an intel mac at the moment. I would love to do some beta testing for you :-)
jrichards
 
Posts: 22
Joined: 08 Jun 2009, 00:38
Location: Provo, Utah

Re: Examples from my postprocessor software

Postby spamsickle » 08 Jun 2009, 14:55

I'm on a PC, I'd be happy if you'd just toss out the source and tell us to get it working ourselves.
spamsickle
 
Posts: 577
Joined: 06 Jun 2009, 23:57

Re: Examples from my postprocessor software

Postby rob » 11 Jun 2009, 11:57

I can post the source code, but I hate doing that without also posting an out-of-the-box working version. It's like we're back in 1992, and software is delicate and you need to config it.

I will post the code, but I will also start working on a 100% Java version. I've been trying to work on compiling Leptonica for architectures other than Mac Intel, but it's proving to be an enormous pain, as well as reminding me why I abandoned C back in 1999. Not only that, and you Core 2 Duo owners might know what I'm talking about -- you have to choose whether to run 64-bit Java or 32-bit Java, and then when you hit a native C library for Java to load, if you don't match the C library's architecture, you are screwed. :cry:

So, here's what you need to do to compile. If you don't know how to do both Java and C development, don't attempt this! Wait for the 100% Java version. :(

1. Install libjpeg
2. install libz
3. Install libtiff (this library depends on libjpeg and libz, so install it after libjpeg and libz).
4. Perhaps needless to say, get Java 5 or Java 6. These should theoretically already be installed on your machine.
5. Get Leptonica. Compile it.
6. If you're on a Mac Core 2 Duo, run Applications/Utilities/Java/Java Preferences and move J2SE 5.0 32-bit to the top.
7. Compile the JLeptonica.java and Test.java files.
8. Run javah on JLeptonica.java to get the native header file.
9. Compile JLeptonicaC.c along with the above native header file.
10. Make it a dynamically loadable library.
11. You should now be able to run the program as follows:

Code: Select all
java -classpath CLASSDIR -Djava.library.path=LIBDIR test.Test L|R IMGDIR


where CLASSDIR is the directory containing the class files,
LIBDIR is the directory containing your JLeptonicaC dynamic library
L|R is L for left-hand page images, or R for right-hand page images
IMGDIR is the directory containing the images from your camera, which must end in .JPG

The camera images must look something like this:

sample.png
sample.png (171.93 KiB) Viewed 2713 times


In addition:

Try to get the page as evenly lit as possible: no hot spots.

The page may be rotated as much as ten degrees either way, and there may be some keystoning caused by having the camera not perfectly centered and not pointing exactly perpendicular to the page.
Attachments
jleptonica.zip
(16.41 KiB) Downloaded 186 times
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
User avatar
rob
 
Posts: 770
Joined: 03 Jun 2009, 13:50
Location: Maryland, United States

Re: Examples from my postprocessor software

Postby spamsickle » 11 Jun 2009, 12:43

Thanks, I'll go grab Leptonica and get to work.

If you're planning to create the all-Java version by porting Leptonica routines into Java, and you think the work can be divided among several developers, I'd be happy to help. I'm somewhat familiar with image processing, and coded some routines myself back when the tools were C, assembler, and Targa.
spamsickle
 
Posts: 577
Joined: 06 Jun 2009, 23:57

PreviousNext

Return to Tutorials/How-To's

Who is online

Users browsing this forum: No registered users and 1 guest