Page 1 of 1

-separate/-combine issue

Posted: 2012-11-06T11:59:01-07:00
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

Re: -separate/-combine issue

Posted: 2012-11-06T12:20:27-07:00
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

Re: -separate/-combine issue

Posted: 2012-11-06T12:31:58-07:00
by spyder
Thanks!!!

May want to correct the command example at:

http://www.imagemagick.org/script/comma ... hp#combine

Re: -separate/-combine issue

Posted: 2012-11-28T22:36:53-07:00
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.