bug when extracting single LAB channel

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
banisco
Posts: 10
Joined: 2016-08-12T15:31:12-07:00
Authentication code: 1151

bug when extracting single LAB channel

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: bug when extracting single LAB channel

Post 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
banisco
Posts: 10
Joined: 2016-08-12T15:31:12-07:00
Authentication code: 1151

Re: bug when extracting single LAB channel

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: bug when extracting single LAB channel

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: bug when extracting single LAB channel

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: bug when extracting single LAB channel

Post by fmw42 »

You can specify numbers in later versions of ImageMagick. For IM 6, 0-5. For IM 7, 0-31
Post Reply