Page 1 of 1

Getting values used for -auto-level?

Posted: 2011-11-23T11:09:39-07:00
by wildbug
I'm working with some raw grayscale image data currently, and I'm a little new to reading raw data. While initially trying to read these files, I was getting solid black images, and I thought I had the wrong arguments until I added -auto-level and the image finally appeared.

That would be good enough, except that I'm working with a series of related images, and -auto-level generates slightly different levels for each of them. I'd like to use the same values for all of them so that they'll be consistent. Is there a way to see what -auto-level is doing or a way to find some sane values for -level that I can then apply to every image?

Re: Getting values used for -auto-level?

Posted: 2011-11-23T11:21:50-07:00
by fmw42
-auto-level (by default) finds the min and max overall values (from the combined RGB channels) and then stretches the min to black and the max to white. (it also can be set to stretch each channel separately by prefacing with -channel RGB)

you can get the overall min and max from the verbose info of the image

convert image -verbose info:

or from string formats

convert image -format "%[min]" info:
convert image -format "%[max]" info:

see
http://www.imagemagick.org/script/escape.php


If you want to get the min and max of all your images, you can write a loop and collect the min and max values and find the min and max of them all. But easier would be to append all the images together and then get the min and max of the appended image.

Then you can just use -level min,max to stretch all the images with the same values.

see
http://www.imagemagick.org/script/comma ... php#append
http://www.imagemagick.org/Usage/layers/#append
http://www.imagemagick.org/Usage/color_mods/#level

Re: Getting values used for -auto-level?

Posted: 2011-11-23T11:30:02-07:00
by wildbug
That's perfect; thank you!