Page 1 of 1

Getting different results when using -channel to contrast-stretch

Posted: 2015-06-09T07:28:13-07:00
by aytac0x
I am getting different result when I apply -contrast-strect 0 on a single channel by using -channel operator and when I use -contrast-strecth after I separate the channels. Any hints why this is the case?

I tried this with LAB LCHab and HSL using latest imagemagick on arch linux.
original image: https://dl.dropboxusercontent.com/u/22023572/a3.png

Using -channel

Code: Select all

convert img.png -colorspace LAB -channel L -contrast-stretch 0 -colorspace sRGB img_lab_only_L_auto.png
result: https://dl.dropboxusercontent.com/u/220 ... uto_a3.png

Doing it "by hand"

Code: Select all

convert img.png -colorspace LAB -separate img_lab_channel_%d.png
convert img_lab_channel_0.png -contrast-stretch 0 img_lab_channel_0_stretched.png
convert img_lab_channel_0_stretched.png img_lab_channel_1.png img_lab_channel_2.png -set colorspace LAB -combine -colorspace sRGB img_lab_only_L.png
result: https://dl.dropboxusercontent.com/u/220 ... y_L_a3.png

Any ideas?

Re: Getting different results when using -channel to contrast-stretch

Posted: 2015-06-09T07:58:58-07:00
by snibgo
Annoyingly, "-channel L" is a synonym for "-channel B", ie the third channel, not the first channel. Use "-channel R" instead.

EDIT: I said "-channel G" but meant "-channel B".

Re: Getting different results when using -channel to contrast-stretch

Posted: 2015-06-10T02:48:59-07:00
by aytac0x
Hmm so L is the L in HSL. At first I thought the problem was about the Sync flag for -channel.

When I looked at the output of

Code: Select all

convert -list channel
i can see A and B as well. That was misleading, So A is for Alpha and B is for Black?

edit: B must be for Blue, I am overthinking... :)

Re: Getting different results when using -channel to contrast-stretch

Posted: 2015-06-10T03:17:24-07:00
by snibgo
A is for Alpha
B is for Blue (the third channel, whatever colour model)

I only ever use R, G, B and A. If I did CMYK work, I would also use those.