Clever combine of multi-stepped process.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
redace

Clever combine of multi-stepped process.

Post by redace »

Greetings Magick gurus!

I've been experimenting with some image enhancement to allow my OCR software to read barcodes better.
I first receive a "poor" scan of a dotmatrix report. This report has a barcode in the corner. My first step was to crop out this barcode from the main image.

Code: Select all

convert document.tif -crop 975x275+0+0 bcode.pnm
Now I enhanced the image by "multiplying" it over itself, making it bolder by shifting a pixel or two vertically.

Code: Select all

/composite -compose multiply -geomtry -0-1 bcode.pnm bcode.pnm boldcode.pnm
Lastly, I 'defuzz' the edges/remove specks with a median.

Code: Select all

convert -median 1 boldcode.pnm
I'd like to combine this 3 phase system into a single script with one in file, and one out file, and skip the 2 intermdiate steps, and hen feed that image to my decoding software. My experiments in combining them aren't working yet. Can anyone shed a light on quick way to merge these? Perhaps a way to store the image internally while processing using file: ?

Thanks in advance for your tips & advice!

Wand-config --version = 6.2.9, RHEL4 2.6.9-42.0.2.ELsmp
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

There may be better ways to do some of the steps, but in general (for IM version 6, not 5) just append the operations one after the other...

You shoud remove the unwanted virtual canvas stuff after the crop (using +repage). Saving to PNM did this automatically as it doesn't understand virtual canvas or page info.

Code: Select all

convert document.tif -crop 975x275+0+0 +repage \
             \( +clone \) -geomtry -0-1 -compose multiply -composite \
             -median 1 boldcode.pnm
Da Daaa....

Note that I use a +clone to double up the image for the multiply, and -geometry to specify the offset for the comming -composite.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply