Newbie: how to make JPEGs o text more legible for a book?

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
bookpub1

Newbie: how to make JPEGs o text more legible for a book?

Post by bookpub1 »

I'm new to ImageMagick (and not much of a graphics person either)... I'm a small book publisher who has to scan old documents for use in a book (documents are all text, no photos or illustrations... 95% typed, 5% handwritten). The scanning is done, into JPEG format, but I have the final task of trying to sharpen up the text (increase the contrast between ink and paper!?) to make it more legible.

I've played a around a bit with the ImageMagick parameters (e.g. contrast and modulate and monochrome and despeckle) and am not going in the right direction... file size is getting smaller and the text less legible.. and I don't think it's that I'm using + instead of - in front of the parameters. For example the first thing I tried was a friend's (also a newbie) suggestion:

/usr/local/bin/mogrify -modulate 120 *

(I'm using ImageMagick 6.1.7 on Mac OS X)

Sharpening/upping the contrast of text against white paper -- what should I be using? I'm betting this is so trivial that some/many of you can save me x hours of banging my head against the wall (whether experimentation or plowing thorough various tip files).

Thanks in advance!
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Newbie: how to make JPEGs o text more legible for a book?

Post by el_supremo »

"-modulate 120" only increases the brightness of the image (see http://imagemagick.org/script/command-l ... p#modulate).
To sharpen an image you need to use either the -sharpen or -unsharp options ("unsharp is an odd name but it does sharpen).
Change "-modulate 120" to "-unsharp 0x1" and see if it does what you want. Unfortunately, there's no easy way to know in advance which values will give you good results so you'll have to play with them. See http://imagemagick.org/script/command-l ... hp#unsharp.

I hope you have a backup of your images. The mogrify command, as you have specified it, modifies and overwrites the original image - it does not create a copy (unless you tell it to, and you didn't).

Pete
bookpub1

Re: Newbie: how to make JPEGs o text more legible for a book?

Post by bookpub1 »

Pete,

Thanks much for the suggestion! I saw the mentions of the sharpness and unsharpness tools but was totally scared off by the documentation:

radius: The radius of the Gaussian, in pixels, not counting the center
pixel (default 0).
sigma: The standard deviation of the Gaussian, in pixels (default 1.0).
amount: The percentage of the difference between the original and the blur
image that is added back into the original (default 1.0).
threshold: The threshold, as a fraction of QuantumRange, needed to apply the
difference amount (default 0.05).

I did fine with calculus in school, but above means nothing to me... I guess ImageMagick is not for the casual user. :->

You suggested that I try "-unsharp 0x1"... how do those 2 parameters relate to the four above?

My text pages are standard American page size 11.0" tall x 8.5" wide... does that info help enable someone to calculate (or guesstimate) any of the 4 parameters in the documentation or tweak your 0x1 parameters?

Again, really appreciate the help! It sounds like ImageMagick is an amazing package... when I'm not on a deadline I'll definitively play with it some!
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Newbie: how to make JPEGs o text more legible for a book?

Post by el_supremo »

The numbers are specified to -unsharp as:
radiusxsigma+amount+threshold
The x and the + signs are only used to separate the numbers and don't mean multiplication or addition.
So my suggestion of 0x1 means radius = 0 (so the program chooses a radius for you) and a sigma of 1. And since I didn't specify them, amount defaults to 1.0 and threshold to 0.05.
I'm afraid I can't offer you any help beyond that. Even if I had one of your images I would have to play with it to find a combination that sharpens well.

Pete
bookpub1

Re: Newbie: how to make JPEGs o text more legible for a book?

Post by bookpub1 »

Pete,

Ok, makes sense... thanks again.

Two more quick questions:

1) re: your suggestion:

0x1 means radius = 0 (so the program chooses a radius for you) and a sigma of 1. And since I didn't specify them, amount defaults to 1.0 and threshold to 0.05.

If I play around with various values, do you recommend I stick with tweaking the radius and sigma? If so, what increments of each do you recommend playing with to see what happens? Should I even try messing with the other two (e.g. vary threshold by multiples of .05)?

2) Is there a layman's resource that explains these variables that you (or others) could refer me to that might step me through these kinds of questions?

Thanks again... really do appreciate it.
bookpub1

Re: Newbie: how to make JPEGs o text more legible for a book?

Post by bookpub1 »

PS-- Found this helpful page on unsharp, though not layman (quite):

http://redskiesatnight.com/Articles/IMsharpen/

Per that article, if my final output images have to be 600 dpi then my (mask) radius should be 4... and it later says that if radius >= 1 then sigma should be set to sqrt(radius)... for me, 2.

Unsharp at Pete's our suggested 0x1 is taking over 20 minutes to do the first image... does this sound right!?? How long would it likely take at above values of radius and sigma?? My PowerPC Mac operates at 1.8 gz but has no special graphics processing hardware... and I have 300 pages to do!! (ouch)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Newbie: how to make JPEGs o text more legible for a book?

Post by anthony »

The most important factor is the sigma. As it is the real control of the sharpening operation. It is only due to hostorical accident it is the second term in the above.
It can be any floating point value from .1 for practically no sharpening to
3 or more for sever shaprening. 0.5 to 1.0 is rather good.

Radius is just a limit of the effect as is the threshold.

Radius is only in interger units as that is the way the algorithm works, the larger it is the slower it is. But it should be at a minumum 1 or better still 2 times the sigma.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply