-separate/-combine issue

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
spyder
Posts: 20
Joined: 2007-05-23T12:03:45-07:00

-separate/-combine issue

Post by spyder »

Running ImageMagick-6.8.0-3 (also tested 6.8.0-4) on Mac OS 10.7.5. Combining an image after separating its channels does not match the original image. I tested with...

convert logo: logo.jpg
convert logo.jpg -channel R -separate logo_red.jpg
convert logo.jpg -channel G -separate logo_green.jpg
convert logo.jpg -channel B -separate logo_blue.jpg
convert logo_red.jpg logo_green.jpg logo_blue.jpg -channel RGB -combine logo_combine.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -separate/-combine issue

Post by fmw42 »

you have confused -channel with -colorspace and misplaced it. try

convert logo: logo.jpg
convert logo.jpg -channel R -separate logo_red.jpg
convert logo.jpg -channel G -separate logo_green.jpg
convert logo.jpg -channel B -separate logo_blue.jpg
convert logo_red.jpg logo_green.jpg logo_blue.jpg -combine -colorspace sRGB logo_combine.jpg

or force the grayscale to be non-linear by avoiding (tricking) it from being linearized

convert logo: logo.jpg
convert logo.jpg -set colorspace RGB -channel R -separate logo_red.jpg
convert logo.jpg -set colorspace RGB -channel G -separate logo_green.jpg
convert logo.jpg -set colorspace RGB -channel B -separate logo_blue.jpg
convert logo_red.jpg logo_green.jpg logo_blue.jpg -combine logo_combine.jpg

Note after IM 6.7.8.3, separated channels, which are gray, have been made linear. This is the root of the issue. see
viewtopic.php?f=4&t=21269
Last edited by fmw42 on 2012-11-28T22:55:33-07:00, edited 1 time in total.
spyder
Posts: 20
Joined: 2007-05-23T12:03:45-07:00

Re: -separate/-combine issue

Post by spyder »

Thanks!!!

May want to correct the command example at:

http://www.imagemagick.org/script/comma ... hp#combine
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: -separate/-combine issue

Post by anthony »

Essentially separated channels has a loss of colorspace information, whcih you must supply.

I have always thought that -combine should specify the colorspace of the result as an argument, which with the current channel setting will determine how many channel images should be merged together. However that is not how it is implemented (historically).

This is why trying to combine CMYK channel images (4 or 5 channels) actually does not work quite right.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply