How to Darken up image text ?

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
JamesTrix

How to Darken up image text ?

Post by JamesTrix »

I am trying to use imagemagick to adjust the brightness levels in a group of images that I want to fax out, The blackness of the print in the original image is very low so I was trying to increase it.

I was playing around in Paintshop Pro with the brightness levels and was able to improve the image. I was trying to do the same thing in imagemagick from the command line so that i can at some stage try and script this. But I was having some problems knowing what to pass on the command line

Here is a image of what I do in paintshop pro

Image

I was trying to run the following command

>convert -brightness-contrast 0.15 Original.tif Original2.tif

but with out any luck could some one please guide me on what i should try and do to increase the brightness of the image or have another method to improve the darkness of the print. Thanks for your help :-)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Darken up image text ?

Post by fmw42 »

try

orig:
Image


convert Picture1.jpg -level 50x100% Picture1_l50x100.jpg
Image

see http://www.imagemagick.org/Usage/color/#level

or

convert Picture1.jpg -gamma 0.5 Picture1_g0p5.jpg
Image

see http://www.imagemagick.org/Usage/color/#level_gamma
JamesTrix

Re: How to Darken up image text ?

Post by JamesTrix »

fmw42 thank you very much for taking the time to post as well as to convert some sample images for me

I tried the level command but when faxing the whole image was turned black this would be down to how my provider I guess converts the images. I converted the image to TIF maybe I should have made it a PDF.

I am also trying -colorspace Gray to try and improve the image to see if that helps but if you have any other ideas please let me know.

And again thanks for your time
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Darken up image text ?

Post by fmw42 »

post a link to one of your actual images so that we can figure out what our issue is and find the best solution for you.
JamesTrix

Re: How to Darken up image text ?

Post by JamesTrix »

Here is a copy of one of the images http://img64.imageshack.us/img64/9053/examplek.png (the real document is a pdf but had to paste it to a png file and remove some of the personal info) but you will get a understanding of the images that i am trying to work with.

When faxing the blacker the font the better. What happens at the moment is the words and numbers in the boxes become very hard to read when faxed. So I have been trying to apply some sort of mask to try and improve the blackness of the font.

Doing a -level 100x20% works pretty well it makes the fonts white and all the background black but as this document is to be faxed it wont work as it will take a hour to send the fax and also use up all of some ones black ink.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Darken up image text ?

Post by fmw42 »

Your font is way too small to bring out detail without aliasing artifacts. You need to enlarge it from your pdf by using -density

try

convert -density 300 image.pdf image.png

Then use -level 50x100% or something like that to darken the text and leave it on a white background.
billbell52

Re: How to Darken up image text ?

Post by billbell52 »

I tried this command and it seemed to work. The density was low so it is hard to see the true result.

convert c:\temp\orig.png -type Grayscale -depth 8 -black-threshold 87% C:\temp\bw.png
JamesTrix

Re: How to Darken up image text ?

Post by JamesTrix »

Thank you both for your examples they both work


fmw42 this is what I used to and it appears to work pretty well

convert -density 300 Case1Original.pdf testmerge.tif
convert -level 50x100% -type grayscale -depth 8 tifmerged.tif tifmerged2.tif


billbell52 you method worked great if the image was a tif or png file but as soon as i converted a mutipage pdf the image quality started showing

convert Case1original.pdf -type grayscale -depth 8 -black-threshold 87% case1.tif

convert Case1original.tif -type grayscale -depth 8 -black-threshold 87% case2.tif (when changing the threshold a little bit more it got even better)

See results

http://img714.imageshack.us/img714/1281/convertpdf.png

I am going to try and convert the PDF to a TIF and then try your method


Thank you again both for your examples and time
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Darken up image text ?

Post by fmw42 »

convert -density 300 Case1Original.pdf testmerge.tif
convert -level 50x100% -type grayscale -depth 8 tifmerged.tif tifmerged2.tif
You can do that in one command

convert -density 300 Case1Original.pdf -level 50x100% -tpe grayscale -depth 8 tifresult.tif

note you can adjust the first value (50) in -level and find the best result for your image.
JamesTrix

Re: How to Darken up image text ?

Post by JamesTrix »

fmw42 again thank you I did not even think of putting the command in to one line sorry its my fault as I miss read one of your early comments.

I have been playing with some of the other commands and trying out a few other examples to try and learn a bit more about imaging and imagemagick.

One thing I have noticed is that the tif images that i am creating are very large in size.

Should I try and compress the tif image or do you think I should try and change the output size at the moment I saw one image at 2479x3508 that sounds pretty big to me as this document is meant to be faxed it does not need to be a very large size.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Darken up image text ?

Post by fmw42 »

If the pixel size is too big, you can resize back down. The -density enlarges the image by about a factor of 4 (4*72dpi = 288 = about 300), so scale it back down.

convert -density 288 Case1Original.pdf -level 50x100% -resize 25% -type grayscale -depth 8 tifresult.tif

or change 25% to whatever reduction size you want.

You can compress the tif also, but you need to be sure you use a compression that is compatible with faxing. see http://www.imagemagick.org/Usage/formats/#tiff
JamesTrix

Re: How to Darken up image text ?

Post by JamesTrix »

Thanks again for the hints, I am trying to get a list of supported TIF formats from my provider as I know they also convert the tif on there side as well before it is sent so it might be a little bit more flexible


I was wanting to try the group3/group4 compression method but kept receiving this error


Bits/sample must be 1 for Group 3/4 encoding/decoding

Is this because of the greyscale command ?


(Wait +matte seems to have done the trick RTFM)
Post Reply