Gimptalk - Premier Gimp Community: Need help batch processing LOTS OF IMAGES - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need help batch processing LOTS OF IMAGES

#1 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 02 March 2012 - 08:02 PM

I have lots of (about 3500) scanned pages, each containing about a dozen "4 option tests".
I want to split each page into 12 parts and save each part into a separate image files.
I want computer software to do this for me, AUTOMATED.
Each "4 option test" has a different vertical size, So I can't set the program to slice each page to 12 equal parts.
The pages are scanned in black and white, I want to pick a pencil from the toolbox and draw a red pixel at top of every "4 option test" as a guide for the software to slice from there, so I will have to draw a total of 11 red pixels in each page.

Please help me in regard to how to do this process. it is very critical for me.
0

#2 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,301
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 02 March 2012 - 09:37 PM

You can't split the pages into equal parts, but would the unequal parts be always the same on the 3500 pages, or a sizeable part of the 3500 pages? Not a job for Gimp in any case, more like a job for ImageMagick and a good scripter.

This post has been edited by ofnuts: 02 March 2012 - 09:38 PM

010011110110011001101110011101010111010001110011
0

#3 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 02 March 2012 - 09:43 PM

 ofnuts, on 02 March 2012 - 09:37 PM, said:

You can't split the pages into equal parts, but would the unequal parts be always the same on the 3500 pages, or a sizeable part of the 3500 pages? Not a job for Gimp in any case, more like a job for ImageMagick and a good scripter.

Each part may have a different and unique size. so part of the job (drawing guide marks) must be done manually. however the slicing and saving part can be done by computer automatically.

How can I write an script to slice the page horizontally from everywhere that I draw a red pixel?

This post has been edited by evil gnome: 02 March 2012 - 09:44 PM

0

#4 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,301
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 03 March 2012 - 09:05 AM

 evil gnome, on 02 March 2012 - 09:43 PM, said:

 ofnuts, on 02 March 2012 - 09:37 PM, said:

You can't split the pages into equal parts, but would the unequal parts be always the same on the 3500 pages, or a sizeable part of the 3500 pages? Not a job for Gimp in any case, more like a job for ImageMagick and a good scripter.

Each part may have a different and unique size. so part of the job (drawing guide marks) must be done manually. however the slicing and saving part can be done by computer automatically.

How can I write an script to slice the page horizontally from everywhere that I draw a red pixel?

Why use a pixel? You would position a "guide" (horizontal or vertical) ( see http://docs.gimp.org...age-guides.html ) and use Image/Transform/Guillotine to split the image at the guide.

This said, this software could be your magic bullet: http://scantailor.sourceforge.net/
010011110110011001101110011101010111010001110011
0

#5 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 03 March 2012 - 12:45 PM

Nice tip. tried setting guides and executing guillotine and it worked. not automated but still MUCH FASTER than the regular method.

Now if there was any way to automate the saving process that would be over.
Is there any way to set guide lines in each page, then let scan tailor split the pages into multiple files from the guide lines?

I registered at diybookscanner.org but my account haven't been activated yet.
0

#6 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 03 March 2012 - 01:56 PM

I'm figuring out a way to make it automated.
I also need a plugin for gimp named "Deskew", but the download website is down and I couldn't find it anywhere. If you happen to have the plugin please upload it for me.
0

#7 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 03 March 2012 - 05:47 PM

 ofnuts, on 03 March 2012 - 09:05 AM, said:

Why use a pixel? You would position a "guide" (horizontal or vertical) ( see http://docs.gimp.org...age-guides.html ) and use Image/Transform/Guillotine to split the image at the guide.

My friend might write a C++ script to split the images inside a folder from red line guides. is there any way to convert "guides" into red pixel lines?
0

#8 User is offline   rich2005 

  • Member
  • PipPip
  • Group: Members
  • Posts: 327
  • Joined: 01-December 10

Posted 03 March 2012 - 06:21 PM

You don't say which OS you are using so I am assuming windows.

You should go back to Ofnuts post and ImageMagick, unfortunately I'm well out of practice with windows batch files but here is a pointer.

The Imagemagick command is simple
convert <infile> -crop Width x Depth +X_coord +Y_coord +repage <outfile>

You have not said how these scans are organized so I am also assuming that there will a number of candidates who have each completed a test book and you can organize the scans into cadidate_page groups.

A skeleton batch file for any particular page will be along the lines of

for %%f in (*.tif); do convert "%%f" -crop 0x75+0+177 +repage "%%f_01.jpg"
for %%f in (*.tif); do convert "%%f" -crop 0x65+0+252 +repage "%%f_02.jpg"

This is just for 2 strips, I'm not a masochist, if you are interested you can add however many you need. The width you can set to 0 which is whatever the image is. Depth and the starting coordinates you can get from Gimp, coordinates of say the paintbrush tool are shown at the bottom. The measure tool can determine the depth. For any page 'set-up' some guides and make sure snap to guides is enabled. You can have any input or output file format, I am using tif & jpg as an example but keep them different.

How would you use it? Have all scans of any one page in a folder with the batch file. In a command window navigate to that folder, run the batch file and it will process each strip through all the pages then move on to the next strip.

A couple of screen shots as an example.

http://i.imgur.com/5uBL5.jpg

luck.
0

#9 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 03 March 2012 - 06:53 PM

NO NO I'm using Lubuntu

Thank you, although I don't understand programming myself. but this would help my friend figure it out way faster and make his job less.
Thanks

This post has been edited by evil gnome: 03 March 2012 - 06:57 PM

0

#10 User is offline   rich2005 

  • Member
  • PipPip
  • Group: Members
  • Posts: 327
  • Joined: 01-December 10

Posted 03 March 2012 - 07:53 PM

 evil gnome, on 03 March 2012 - 06:53 PM, said:

NO NO I'm using Lubuntu

Thank you, although I don't understand programming myself. but this would help my friend figure it out way faster and make his job less.
Thanks


Ok I'm sure your friend is well up on this, (I gave up coding with quickbasic 4.5 LOL) the equivalent bash file is

#!/bin/bash
find . -name "*.tif" | while read fname ; do
echo "Doing: $fname"
convert "$fname" -crop 0x75+0+177 +repage "${fname%%tif}1.jpg"
convert "$fname" -crop 0x65+0+256 +repage "${fname%%tif}2.jpg"
done

even more luck
0

#11 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,301
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 03 March 2012 - 08:23 PM

 rich2005, on 03 March 2012 - 07:53 PM, said:

I gave up coding with quickbasic 4.5 LOL

  • s/with/because of/
  • "quickbasic 4.5 LOL". yes, that's also its name in development circles :)

010011110110011001101110011101010111010001110011
0

#12 User is offline   rich2005 

  • Member
  • PipPip
  • Group: Members
  • Posts: 327
  • Joined: 01-December 10

Posted 03 March 2012 - 08:40 PM

 ofnuts, on 03 March 2012 - 08:23 PM, said:

 rich2005, on 03 March 2012 - 07:53 PM, said:

I gave up coding with quickbasic 4.5 LOL

  • s/with/because of/
  • "quickbasic 4.5 LOL". yes, that's also its name in development circles :)



Ah you young guys, I'm just an old engineer. Back in 1970-ish it was FORTRAN, very sensible eg. INteger variables started with I,J,K,L,M or N - easy-peasy. Later in M$DOS QB4.5 was not a bad little compiler for the time. I still have the 2 720KB 3.5" installation disks + 2 large manuals that went with it. Then along came Windows and event-driven procedures. It all became very verbose and I lost interest. Still fiddle around a little with FreeBasic.
0

#13 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,301
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 04 March 2012 - 12:01 AM

 rich2005, on 03 March 2012 - 08:40 PM, said:

 ofnuts, on 03 March 2012 - 08:23 PM, said:

 rich2005, on 03 March 2012 - 07:53 PM, said:

I gave up coding with quickbasic 4.5 LOL

  • s/with/because of/
  • "quickbasic 4.5 LOL". yes, that's also its name in development circles :)



Ah you young guys, I'm just an old engineer. Back in 1970-ish it was FORTRAN, very sensible eg. INteger variables started with I,J,K,L,M or N - easy-peasy. Later in M$DOS QB4.5 was not a bad little compiler for the time. I still have the 2 720KB 3.5" installation disks + 2 large manuals that went with it. Then along came Windows and event-driven procedures. It all became very verbose and I lost interest. Still fiddle around a little with FreeBasic.
This "young guy" learned programming in Fortran and in the late 70s on an IBM1130 with 8K RAM. But took C instea of QBasic, so is still coding :)
010011110110011001101110011101010111010001110011
0

#14 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 04 March 2012 - 06:39 AM

This problem of mine, made me decide to start learn coding. where should I start? I want to code in python.

BTW My friend is going to write an small C++ program that does this:

I will add 1 pixel red lines to the big images and save them
I put all the images in a folder
Run the program
The program will divide all images in the folder, according to the 1 pixel red lines
Then will save all the little parts into separate jpeg files, and name them like (00001, 00002, 00003....)


NOW THE NEW PROBLEM:
I want gimp to draw 1 pixel red lines wherever I put "ruler guides". because It is much easier than drawing lines by mouse.
I simply add as many horizontal "guides" as I want, and run a gimp command, and bang... guides are converted to 1 pixel red lines.
How can I accomplish this?
Please help

This post has been edited by evil gnome: 04 March 2012 - 09:57 AM

0

#15 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,301
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 04 March 2012 - 02:11 PM

 evil gnome, on 04 March 2012 - 06:39 AM, said:

This problem of mine, made me decide to start learn coding. where should I start? I want to code in python.

BTW My friend is going to write an small C++ program that does this:

I will add 1 pixel red lines to the big images and save them
I put all the images in a folder
Run the program
The program will divide all images in the folder, according to the 1 pixel red lines
Then will save all the little parts into separate jpeg files, and name them like (00001, 00002, 00003....)


NOW THE NEW PROBLEM:
I want gimp to draw 1 pixel red lines wherever I put "ruler guides". because It is much easier than drawing lines by mouse.
I simply add as many horizontal "guides" as I want, and run a gimp command, and bang... guides are converted to 1 pixel red lines.
How can I accomplish this?
Please help
Your approach doesn't look right because in the end it generates as much work (if not more) than doing the things in Gimp manually... If you open image "foo.jpg" in Gimp, set up guides, and use Guillotine, you get sub-images that are pre-named with unique names (original+sequence) and that will be saved/closed using a mere "click on it, Ctrl-S, Ctrl-W" for PNG (you don't get through the usual PNG save options in this case) and "click on it, Ctrl-S, [Enter], Ctrl-W" for JPG. If the names you obtain do not suit you, writing a script to rename the files is easy. So, assuming you have assigned "Guillotine" to a keyboard shortcut, to split an image in N you need N-1 drag for guides, N clicks, and 2N or 3N keyboard actions. You could write a script (or have it written) to do the "guillotine/save under right name" in one keystroke to save the final save operations. But anything you will do to indicate to some external program where to cut is going to take more time than this, unless you script it but then you can as well script the save operation above.

But the real time-saver is to avoid going over the 3500 files by hand to indicate where to split them. If there is any chance that these pages have some common structure (scanned answer sheets)? then you should be able to do a rough cut automatically.

Can you post a sample page or two (some you'll classify as "difficult" so that we can see what we are talking about?

This post has been edited by ofnuts: 04 March 2012 - 02:14 PM

010011110110011001101110011101010111010001110011
0

#16 User is offline   evil gnome 

  • Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 02-March 12

Posted 04 March 2012 - 10:05 PM

This is a sample.


My friend is writing a c++ program that will extract each test and save it in a separate file and name it according to the number of each test. ALL AUTOMATICALLY. he is great. no more red lines needed anymore (or opening any image)

Attached File(s)


This post has been edited by evil gnome: 04 March 2012 - 10:09 PM

0

#17 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,301
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 05 March 2012 - 01:03 AM

 evil gnome, on 04 March 2012 - 10:05 PM, said:

This is a sample.


My friend is writing a c++ program that will extract each test and save it in a separate file and name it according to the number of each test. ALL AUTOMATICALLY. he is great. no more red lines needed anymore (or opening any image)

From what I understand you'll have several copies of the same page (ie, Page 1 for all tested people, page 2 for all tested people, etc...). If you process together all these copies you need to determine where to cut them only once if the scans have been done properly. This can be fed to a script that uses ImageMagick or equivalent to extract that part of the image in all the copies.

This post has been edited by ofnuts: 05 March 2012 - 01:05 AM

010011110110011001101110011101010111010001110011
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic