Page 1 of 1
-separate lowers tones?
Posted: 2012-10-26T00:03:15-07:00
by snibgo
"-separate" followed by "-combine" significantly lowers the middle tones of an image.
For example:
Code: Select all
convert logo: log.tiff
convert logo: -channel RGB -separate log_%d.tiff
convert log_0.tiff log_1.tiff log_2.tiff -channel RGB -combine logCopy.tiff
log.tiff and logCopy.tiff should be identical, but the copy is significantly darker. (Workaround: insert "-gamma 2.2" or "-set colorspace RGB" before the "-separate".)
Leaving off the "-channel RGB" makes no visible difference. From experiments with photographs, it seems the darkening is occurring during the "-separate".
6.7.9-6 2012-09-13 Q16 on Windows.
Re: -separate lowers tones?
Posted: 2012-10-26T04:10:27-07:00
by magick
Add -set colorspace sRGB to your command line. The channels are stored as linear grayscale. Once you combine them you must hint that the channels are non-linear sRGB rather than linear RGB.
Re: -separate lowers tones?
Posted: 2012-10-26T20:02:49-07:00
by snibgo
Add -set colorspace sRGB to your command line.
Which command line: the separate, combine or both? Adding it just before the "-separate" or after the "-combine" doesn't help. Adding it before the "-combine" makes it worse.
The documentation (
http://www.imagemagick.org/script/comma ... hp#combine ) says the commands are inverse, but that seems to be untrue. "-separate" doesn't simply copy pixel values, but instead converts from (assumed sRGB) non-linear values to linear values. However, "-combine" then copies the pixel values with no conversion. "Identify" then says the resulting logCopy.tiff is sRGB, although it isn't.
As I mentioned in the OP, adding "-set colorspace RGB" before the "-separate" doesn't convert the pixel values.
This seems to be a bug in either the documentation or the behaviour of one of the "-separate" or "-combine" commands.
Re: -separate lowers tones?
Posted: 2012-10-26T20:22:50-07:00
by fmw42
When you now (in current versions of IM as of about IM 6.7.8.3) separate channels of an sRGB color image, they become linear grayscale rather than in the old days as nonlinear (sRGB) grayscale. To fix this now do something like
convert image -set colorspace RGB -separate separateimages_%d.png
or with any other colorspace conversion as well
convert image -set colorspace RGB -colorspace HSL hslseparateimages_%d.png
When combining
convert separateimages_*.png -combine -colorspace sRGB combined.png
or
convert hslseparateimages_*.png -set colorspace HSL -combine -colorspace sRGB hslcombined.png
The issue is to trick IM to treat the input color image as if it was already linear, so that IM does not convert to linear.
See
viewtopic.php?f=4&t=21269
Re: -separate lowers tones?
Posted: 2012-10-26T20:58:13-07:00
by snibgo
Agreed. But I think the "-combine" behaviour is wrong. It copies the pixel values from the separate greyscale files without conversion, but the resulting file (according to "identify") is sRGB.