Page 1 of 1

Can IM define output levels as in Photoshop?

Posted: 2011-10-08T05:47:11-07:00
by the-ninth
Hi,

The Levels filter from Photoshop can define Output Levels, i.e. the highest and lowest luminance values to be used in the image.

The ImageMagick -level parameter does not have these settings. Is there any other way to achieve them?

Thanks, Robert

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-09T10:40:49-07:00
by fmw42

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-09T11:51:08-07:00
by the-ninth
Hi Fred,

How would I have to use these functions to achieve the Photoshop Output Level result? These functions seem to focus on the stretching aspect of the Levels filter, but the Output Level is more a compression. For example, take the whole luminance range of 0-255 of a given a picture and compress it to a window of 0-215. In this example there would not be any real white in the picture any more.

Cheers, Robert

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-09T13:06:43-07:00
by fmw42
Robert,

I am not sure what you wanted to do. I thought you wanted to specify the clip values so as to stretch the image. If you don't want to stretch the image, but compress the values, then use -level to increase contrast or +level to decrease contrast. It works on raw graylevel values or percent graylevel values (not percent counts as does -contrast-stretch). And they both allow a gamma value

I believe from what you are asking you need to use +level

However, the raw graylevel values are dependent upon your IM compile Q value. For Q16 those values would be 0 to 65535. For Q8 they would be 0 to 25. So the best thing would be to convert your values to percent, i.e. 100x215/255=84%. So you would use +level 0x84%

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

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-09T19:15:08-07:00
by anthony
To only level luminance, convert the image to a colorspace with luminance, and level just that!

For example...

Code: Select all

   convert rose: -colorspace HSL -channel B -level 25,75% +channel -colorspace RGB rose_level_luminance.png
NOTE in HSL colorspace luminance is stored in the 'Blue' channel.
See Separating Channels.
http://www.imagemagick.org/Usage/color_basics/#separate

I don't have a section specifically taking about HSL/HSB colorspace as yet, just indirectly as part of various operators.

Also see Modulate Operator
http://www.imagemagick.org/Usage/color_mods/#modulate

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-09T20:15:07-07:00
by fmw42
Better to use YUV or YCbCr to get the luminance channel to level. The luminance channel is the Y or first channel in both cases.

see
http://www.imagemagick.org/script/comma ... colorspace

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-10T01:27:08-07:00
by the-ninth
Thanks guys, I'll try these commands.

Cheers, Robert

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-10T11:01:43-07:00
by fmw42
To adjust the input and output levels, you probably need to use a combination of -level followed by +level.

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-12T14:30:13-07:00
by fmw42
I have uploaded a new script, levels, to my web site below, to simulate the Photoshop-like levels processing.

Re: Can IM define output levels as in Photoshop?

Posted: 2011-10-12T18:02:19-07:00
by the-ninth
Hi Fred,

Thanks a lot, that is very useful!

Cheers, Robert