Page 1 of 1

bug when extracting single LAB channel

Posted: 2016-08-12T15:59:18-07:00
by banisco
Converting an sRGB PNG file to LAB colorspace before separating channels works fine; however if I attempt to limit it to a specific LAB channel the output is inconsistent. (I get the same results if I start with a LAB colorspace TIFF and don't perform any colorspace conversion.)

magick foo.png -colorspace CIELab -separate foo_channel_%d.png
(works; channel_0 = Lightness, channel_1 = A, channel_2 = B, channel_3 = Alpha)

Limiting the output to a specific channel:
magick foo.png -colorspace CIELab -channel X -separate foo_channel_X.png (where X is one of Lightness|A|B|Alpha)

I get the following:
Channel L generates B output
Channel A generates Alpha output
Channel B generates B output
Channel Alpha generates Alpha output

magick -version
Version: ImageMagick 7.0.2-7 Q8 x64 2016-08-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

Re: bug when extracting single LAB channel

Posted: 2016-08-12T16:02:30-07:00
by fmw42
How are you specifying -channel X. IM does not use L(or lightness),A,B for channels nor channel numbers for LAB. A is always alpha. You need to use R,G,B to correspond to L,A,B.

see http://www.imagemagick.org/script/comma ... hp#channel

Re: bug when extracting single LAB channel

Posted: 2016-08-15T09:46:06-07:00
by banisco
Ah. I assumed the channel names should have corresponded to those provided by "-list channel". (The docs do suggest this: "To print a complete list of channel types, use -list channel."). But I see they are explicitly not valid '-channel' inputs per the docs.

Thank you for the clarification.

Re: bug when extracting single LAB channel

Posted: 2016-08-15T10:02:14-07:00
by snibgo
This is the list I get for "-list channel":

Code: Select all

A
All
Alpha
B
Black
Blue
C
Cyan
Default
G
Gray
Green
H
Hue
Index
K
L
Lightness
Luminance
Magenta
Matte
M
O
Opacity
Red
R
Saturation
S
Sync
Y
Yellow
The list is a bit weird. For example, it has "Saturation" (which would be for colorspace HSL etc) but not "Chroma" (for HCL). These always refer to specific position of the channels, so for example you could refer to Cyan, Magenta and Yellow channels even when the colorspace has Red, Green and Blue channels.

In other words, "-channel Red" and "-channel Cyan" always refer to the first channel, whether the colorspace is RGB, CMY, Lab or anything else.

Personally, I always use R, G and B (and A for Alpha), instead of any of the others. B stands for Blue, the third channel, not for Brightness or the b* channel of L*a*b*, although those channels by good fortune happen to be in the third position.

The system does cause confusion. I'd be happier if we could use numbers: 0, 1, 2 or whatever.

Re: bug when extracting single LAB channel

Posted: 2016-08-15T10:08:31-07:00
by fmw42
The system does cause confusion. I'd be happier if we could use numbers: 0, 1, 2 or whatever.
Yes, I would agree, especially for IM 7 where more than 5 channels are possible. That would make it easier for all colorspaces, also.

Re: bug when extracting single LAB channel

Posted: 2018-03-05T15:31:56-07:00
by fmw42
You can specify numbers in later versions of ImageMagick. For IM 6, 0-5. For IM 7, 0-31