Page 1 of 1

change of colors while convert

Posted: 2013-03-16T04:02:38-07:00
by ebel
Hi all,
I have a color problem while adding a frame left and right to a picture. How can I avoid that the color changes?

Here is what I have done:
I try to add a 39 pixel frame left and right of my image with ...

Code: Select all

convert 00001.tif -bordercolor Black -frame 39x0 00001_changed.tif
but it changes the colors with a green tint.
I checked the properties of my images with ...

Code: Select all

identify -verbose 00001.tif > 00001.info;identify -verbose 00001_changed.tif > 00001_changed.info; 
I compared the differences with ...

Code: Select all

diff 00001.info 00001_changed.info
and thing the problem is here

Code: Select all

< tiff:photometric: YCBCR
< tiff:rows-per-strip: 2
---
> tiff:photometric: RGB
> tiff:rows-per-strip: 1
Here the complete output of diff
1c1
< Image: 00001.tif
---
> Image: 00001_changed.tif
4c4
< Geometry: 1920x1080+0+0
---
> Geometry: 1998x1080+0+0
6c6
< Print size: 26.6667x15
---
> Print size: 27.75x15
21,24c21,24
< mean: 85.1507 (0.333924)
< standard deviation: 56.0816 (0.219928)
< kurtosis: -1.42352
< skewness: 0.088851
---
> mean: 89.2049 (0.349823)
> standard deviation: 58.5402 (0.229569)
> kurtosis: -1.38967
> skewness: 0.0849196
28,31c28,31
< mean: 79.9954 (0.313707)
< standard deviation: 56.0601 (0.219843)
< kurtosis: -1.36442
< skewness: 0.222793
---
> mean: 84.2508 (0.330395)
> standard deviation: 58.871 (0.230867)
> kurtosis: -1.34246
> skewness: 0.215455
35,38c35,38
< mean: 78.7228 (0.308717)
< standard deviation: 56.224 (0.220486)
< kurtosis: -1.36715
< skewness: 0.251497
---
> mean: 83.0279 (0.3256)
> standard deviation: 59.1097 (0.231803)
> kurtosis: -1.34518
> skewness: 0.2426
43,46c43,46
< mean: 81.2896 (0.318783)
< standard deviation: 56.122 (0.220086)
< kurtosis: -1.38436
< skewness: 0.187721
---
> mean: 85.4945 (0.335273)
> standard deviation: 58.8408 (0.230748)
> kurtosis: -1.35917
> skewness: 0.180792
54c54
< Page geometry: 1920x1080+0+0
---
> Page geometry: 1998x1080+0+0
60,62c60,63
< date:create: 2013-03-16T10:39:44+01:00
< date:modify: 2013-03-15T20:25:39+01:00
< signature: b15ed54e476cc5cc820a70f8adfa9059740bfa44b6a12e83617472442cd08fe8
---
> date:create: 2013-03-16T11:47:48+01:00
> date:modify: 2013-03-16T11:47:48+01:00
> signature: a903bcd357b34c1c8f36b62f803eee18901873318eff0580609cf9c373d66dfb
> tiff:document: 00001_changed.tif
64,65c65,66
< tiff:photometric: YCBCR
< tiff:rows-per-strip: 2
---
> tiff:photometric: RGB
> tiff:rows-per-strip: 1
70,74c71,75
< Filesize: 2.916MBB
< Number pixels: 2.074MB
< Pixels per second: 51.84MB
< User time: 0.030u
< Elapsed time: 0:01.039
---
> Filesize: 5.845MBB
> Number pixels: 2.158MB
> Pixels per second: 215.8MB
> User time: 0.010u
> Elapsed time: 0:01.009

Re: change of colors while convert

Posted: 2013-03-16T07:43:38-07:00
by snibgo
As you've noticed, the input image is in YCC colorspace, which is quite unusual. Perhaps IM isn't converting it properly, and needs to be told how to do it. Try:

Code: Select all

convert 00001.tif -set colorspace YCC -colorspace sRGB 00001_srgb.tif
"-set colorspace YCC" tells IM the image is in YCC colorspace.
"-colorspace sRGB" converts it to sRGB.
If this doesn't work, can you put 00001.tif somewhere, and post the URL here?

However, my experiments with colorspaces suggest that YCC has a problem; it isn't reversible. Given an image in.png, in sRGB space, the command ...

Code: Select all

convert in.png -colorspace YCC -colorspace sRGB out.png
... should make no change, but it does. out.png is darker than in.png. I don't know if this is an IM bug, or a "feature" of YCC.

Re: change of colors while convert

Posted: 2013-03-16T08:49:15-07:00
by fmw42
However, my experiments with colorspaces suggest that YCC has a problem; it isn't reversible. Given an image in.png, in sRGB space, the command ...
CODE: SELECT ALL
convert in.png -colorspace YCC -colorspace sRGB out.png

... should make no change, but it does. out.png is darker than in.png. I don't know if this is an IM bug, or a "feature" of YCC.
Closest I can come is

convert logo: -set colorspace RGB -colorspace YCC -colorspace RGB -colorspace sRGB show:

But the white background is gray. Perhaps this should be reported as a potential bug or a request for clarification on the correct way to do the round trip.

Oddly, I get the same result doing it this way:

convert logo: -set colorspace RGB -colorspace YCC -separate +channel -set colorspace YCC -combine -colorspace sRGB show: