Need help batch processing LOTS OF IMAGES
#1
Posted 02 March 2012 - 08:02 PM
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.
#2
Posted 02 March 2012 - 09:37 PM
This post has been edited by ofnuts: 02 March 2012 - 09:38 PM
#3
Posted 02 March 2012 - 09:43 PM
ofnuts, on 02 March 2012 - 09:37 PM, said:
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
#4
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:
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/
#5
Posted 03 March 2012 - 12:45 PM
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.
#6
Posted 03 March 2012 - 01:56 PM
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.
#7
Posted 03 March 2012 - 05:47 PM
ofnuts, on 03 March 2012 - 09:05 AM, said:
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?
#8
Posted 03 March 2012 - 06:21 PM
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.
#9
Posted 03 March 2012 - 06:53 PM
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
#10
Posted 03 March 2012 - 07:53 PM
evil gnome, on 03 March 2012 - 06:53 PM, said:
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
#11
Posted 03 March 2012 - 08:23 PM
rich2005, on 03 March 2012 - 07:53 PM, said:
- s/with/because of/
- "quickbasic 4.5 LOL". yes, that's also its name in development circles

#12
Posted 03 March 2012 - 08:40 PM
ofnuts, on 03 March 2012 - 08:23 PM, said:
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.
#13
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:
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.
#14
Posted 04 March 2012 - 06:39 AM
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
#15
Posted 04 March 2012 - 02:11 PM
evil gnome, on 04 March 2012 - 06:39 AM, said:
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
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
#16
Posted 04 March 2012 - 10:05 PM
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)
-
DSCF1429.jpg (208.01K)
Number of downloads: 7
This post has been edited by evil gnome: 04 March 2012 - 10:09 PM
#17
Posted 05 March 2012 - 01:03 AM
evil gnome, on 04 March 2012 - 10:05 PM, said:
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

Help












