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

Batch Processing in Gimp?

Discussions, questions, comments, ideas, and your projects having to do with DIY Book Scanner software. This includes the Stereo Data Maker software for the cameras, post-processing software, utilities, OCR packages, and so on.
Post Reply
umpausewhat
Posts: 22
Joined: 04 Mar 2014, 00:55

Batch Processing in Gimp?

Post by umpausewhat » 02 Mar 2011, 01:47

Hi all,

I'm trying to come up with a script (or plug-in) for gimp that will batch process my jpegs to correct for barrel distortion and am wondering if any of you program in scheme. Gimp has a plugin for correcting barrel distortion, so I'm hoping it's not too complicated to ask gimp to run this process with uniform parameters on a set of files. Not knowing much of anything about programming, I've tried to adapt other scripts I've found on the internet to suit my purposes, but I haven't made anything work yet. Just thought I'd check here in case any of you would also have use for such a script and might be able to write it with minimum inconvenience. Sample batch scripts/plug-ins can be found in the gimp registry (http://registry.gimp.org/); I've also tried to adapt the script found here: http://www.gimp.org/tutorials/Basic_Batch/.

I know this won't be of use to everyone, but with a bkrpr build, it would theoretically work well insofar as the camera is always the same distance from the page and thus, I'm guessing, the barrel distortion is uniform for all the pictures. The downside of the bkrpr build is that barrel distortion is, in my experience, unavoidable. The distortion isn't bad for books under 8.5 inches tall, but much beyond that, it becomes distracting. If gimp could be used to correct for this, I think my scanning process would finally be optimized.

I'm using Windows Vista, if that makes a difference. If I end up finding a way to make it work, I'll post my results here. If any of you think you can accomplish this easily, I'd be grateful.

steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Batch Processing in Gimp?

Post by steve1066d » 02 Mar 2011, 01:51

You may want to take a look at Bookscanwizard, as it can correct for barrel (as well as perspective) distortion.
Steve Devore
BookScanWizard, a flexible book post-processor.

User avatar
daniel_reetz
Posts: 2797
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: Batch Processing in Gimp?

Post by daniel_reetz » 02 Mar 2011, 02:56

Seconding BSW, it's being built from the ground up to be the ideal software for this kind of application.

Anonymous1

Re: Batch Processing in Gimp?

Post by Anonymous1 » 02 Mar 2011, 10:09

I used the GIMP for batch autocropping, but I've found that ImageMagick can do everything that GIMP can:

Code: Select all

convert foo.png -fill white -box "Red" -gravity South -pointsize 20 -annotate +0+5 "Foobar" foo.jpg
I'd also use BSW. Steve's really good with all this image-processing stuff.

umpausewhat
Posts: 22
Joined: 04 Mar 2014, 00:55

Re: Batch Processing in Gimp?

Post by umpausewhat » 02 Mar 2011, 13:46

Thanks for the quick replies. I'm trying to install BSW, but am having some trouble (I posted my problem in the BSW thread). If I understand what BSW does, my only qualm is that my bkrpr build does not ensure that the book page will occupy the same position in every picture, so auto-cropping might not work in making all the pages look uniform. I might still need Scan Tailor's detection capabilities. But if BSW will allow me to just correct for the barrel distortion, I could do the rest in Scan Tailor.

I'll look more into ImageMagick, but at first blush, it seems just as intimidating as finding out a scheme script for GIMP.

steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Batch Processing in Gimp?

Post by steve1066d » 02 Mar 2011, 14:01

Yes, that's one of the advantages of ScanTailor.. because it processes each page individually, you can potentially get less movement from page to page if the book moves from page to page (though it does take longer).

Be sure to create the tiff files with no compression if you do use BSW with Scan Tailor (BSW & Scan Tailor don't have a compatible way of handling compressed images).

As far as a process of using both BSW & Scan Tailor, I'd recommend you do fix the barrel distortion, perspective distortion, and do a rough crop in BSW (if necessary), then do the rest of the processing in Scan Tailor.
Steve Devore
BookScanWizard, a flexible book post-processor.

scribbleed

Re: Batch Processing in Gimp?

Post by scribbleed » 16 Mar 2011, 02:17

I just would like to chip in (my first post!).

Have a look at http://hugin.sourceforge.net/, with which you could fine tune your barrel distortion correction (see tutorials). It does have a batch process function (I think you need to switch off panorama stitching), but I am not sure if you can invoke it without starting the program, if that is what you want. But once you have the a,b,c,d, parameters (use a grid picture), I think you can try to find the original http://panotools.sourceforge.net/ program, PTOptimizer, which should work from the command line.

On a related note, UFRaw, which Gimp uses, gets information from the LensFun library, so it might just have your camera configuration (http://ufraw.sourceforge.net/lensfun.html). Not sure how to invoke that from a script though.

Post Reply