Page 1 of 1

-set colorspace

Posted: 2014-01-09T21:58:06-07:00
by GreenKoopa
Does -set colorspace modify pixel values, or only change the colorspace setting?

convert -size 500x1 gradient:#000-#F00 gradient:#FF0-#000 -set colorspace RGB -resize 450x1 -set colorspace sRGB -append y.png
convert -size 500x1 gradient:#000-#F00 gradient:#FF0-#000 -set colorspace RGB -resize 450x1 -append -set colorspace sRGB z.png
compare -metric ae y.png z.png null:
> 226

Re: -set colorspace

Posted: 2014-01-09T22:47:19-07:00
by fmw42
It only sets the colorspace (gamma) in the meta data without changing pixel values. To modify the pixels you need to use -colorspace not -set colorspace.

I am not sure why -append is behaving differently. But in one case you are appending linear RGB and then setting it to sRGB. In the other case you are setting the individual images from RGB to sRGB and then appending.

What happens if you simplify it further and just append two different graylevel 1x1 pixels, say one white and one black?

What version of IM are you using and what platform? It may be you are using too old a version of IM?

I can reproduce your results on IM 6.8.8.1 Q16 Mac OSX. If I use one black and one white pixel, it gives zero for the compare -metric AE.

Re: -set colorspace

Posted: 2014-01-10T01:18:22-07:00
by snibgo
"-set colorspace" doesn't change pixel values. It does change the meaning of those values.

I don't know why there is a difference. If we remove each "-resize", the difference actually increases slightly. However, the RMSE difference is tiny. Really, really small. About 0.3 out of 65535. I would put this down to a rounding difference.

if I run the tests with IM7 (floating point) I get zero difference for both AE and RMSE.

Re: -set colorspace

Posted: 2014-01-10T01:34:43-07:00
by GreenKoopa
snibgo wrote:I would put this down to a rounding difference.
Agreed that it is small, but are pixels being rounded by -append or -set colorspace?

ImageMagick 6.8.8-1 Q16 x64 2013-12-25 on Windows 7

Re: -set colorspace

Posted: 2014-01-10T02:14:24-07:00
by snibgo

Code: Select all

%I%convert ^
  -size 500x1 gradient:#000-#F00 gradient:#FF0-#000 ^
  -set colorspace RGB ^
  -append -write z0.png -set colorspace sRGB ^
  z.png
IM v6.8.8-0 reports zero difference between z0.png and z.png. I conclude the difference comes from the "-append".

Re: -set colorspace

Posted: 2014-01-13T05:31:42-07:00
by GreenKoopa
Agreed, it appears that -append carries out implicit colorspace conversions. I believe that it automatically converts all images to sRGB before appending the images together, then converts the result to the colorspace of the first image. This would explain the above rounding error, and the lost processing time I noticed in an earlier post. I was appending two linear RGB images together into a new linear RGB image, and I didn't realize that -append moved everything through the sRGB colorspace. In conclusion, I didn't expect the rounding error because I didn't know -append had the ability to modify pixel values.