Image conversion to Grayscale using ImageMagick is very dark
Asked Answered
A

1

12

I converted a bunch of "normal" JPG photos via

convert infile -colorspace Gray outfile

to monochrome. However the result is for all images very dark. Here a sample conversion: original photo and converted monochrome image.

Is there a better way to convert a photo-realistic image with ImageMagick to gray-scale?

Alembic answered 14/3, 2013 at 1:34 Comment(2)
Sounds about right. Do you have examples?Hamon
Yep, just added a sample conversion.Alembic
H
18

The documentation states that when changing the color space, the colors are converted from their original gamma to linear before the conversion. You need to convert them back to an appropriate gamma.

convert infile -colorspace Gray -gamma 2.2 outfile
Hamon answered 14/3, 2013 at 4:27 Comment(3)
Great idea. Is there an easy way to find out the gamma a jpg was "recorded" with?Alembic
@halloleo, standard images are always 2.2 unless they were generated on an old Mac.Hamon
I just found this answer for a similar question. It says to convert the RGB values via the formula: Y = 0.30 x Red + 0.59 x Green + 0.11 x Blue This looks to me like a very different approach. Do I have to do both??? I'll try it out.Alembic

© 2022 - 2024 — McMap. All rights reserved.