Page 1 of 1

-auto-level does not work

Posted: 2018-11-25T10:31:55-07:00
by Jack_Brody
I am trying to run:

Code: Select all

magick in.jpg -auto-level out.jpg
I get visually equal image and the histogram does not get stretched. But it is different: the central "peak" is higher so it actually does something.

You may check out my in.jpg and out.jpg here, along with images produced with autolevel functions of XnView and Gimp (these got stretched as expected): ... QujYa?dl=0

Is it a bug or am I doing something wrong?

My system:
Win7 x64 SP1

Version: ImageMagick 7.0.8-14 Q16 x64 2018-10-24
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Visual C++: 180040629
Features: Cipher DPC HDRI
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr
lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib

Re: -auto-level does not work

Posted: 2018-11-25T11:32:00-07:00
by snibgo
You are writing to JPEG, which is a lossy format. That means the compression changes pixel values. I suggest you write to a non-lossy format. I expect you will then find the result is as expected.

Re: -auto-level does not work

Posted: 2018-11-25T11:44:15-07:00
by fmw42
Your image is stretched fully in 2 channels and the other channel min is 9 and max is 255. So you should not expect any change or only a slight change that might not be visible, because global statistics will be used which is 0 and 255. You could do

Code: Select all

convert in.jpg -channel rgb -auto-level out.png
to make each channel stretch to full dynamic range independently.

Re: -auto-level does not work

Posted: 2018-11-25T12:58:57-07:00
by Jack_Brody
That actually does not make much difference as well but it's better a little bit.
But anyway, thank you for your help. I have just found out that -normalize looks like what I need. :)

I kindly ask the administrator to move this thread to a more appropriate section as this apparently is not a bug. Thank you.