Page 1 of 1

dds to png conversion colors wrong

Posted: 2016-04-28T12:03:20-07:00
by videomike99
Hi All.
I'm new to ImageMagick, and am trying to convert an existing .dds image to .png, (or anything else for that matter).
Here's my command string:
convert colorbars.dds -set colorspace ycbca -colorspace rgb newfile.png

The original image can be found here: http://www.video-impressions.com/images/colorbars.dds

All of my conversion attempts either come out purple-ish, or green-ish, so I'm guessing it's a channel thing, but I'm just not that familiar with the program yet.

Any help would be appreciated.
Thanks,

Mike

Re: dds to png conversion colors wrong

Posted: 2016-04-28T12:24:51-07:00
by dlemstra
What is your operating system and your ImageMagick version? And what is wrong with the output? It does contain green-ish and purple-ish values. Can you post your output somewhere?

Re: dds to png conversion colors wrong

Posted: 2016-04-28T13:19:00-07:00
by videomike99
Windows 7 64bit
ImageMagick -6.9.3-Q16
Input file: http: http://www.video-impressions.com/images/colorbars.dds
Output file: http://www.video-impressions.com/images/newfile.png
What file should look like: http://www.video-impressions.com/images/ColorBars.png

The output is purple-ish when opened in photoshop.

Thanks for your assistance!

Re: dds to png conversion colors wrong

Posted: 2016-04-28T13:35:41-07:00
by fmw42
convert colorbars.dds -set colorspace ycbca -colorspace rgb newfile.png
Is ycbca a type? Should it not be YCbCr? Also you should be using -colorspace srgb (for current versions of IM).

Code: Select all

convert colorbars.dds -set colorspace ycbcr -colorspace srgb newfile.png
Nevertheless, the above does not convert to match your colorbars.png on IM 6.9.3.8 Q16 Mac OSX. So are you sure the input DDS is really colorspace YCbCr?

Re: dds to png conversion colors wrong

Posted: 2016-04-28T14:02:54-07:00
by videomike99
Sorry...I had a typo. :?
Below is the command string:

convert colorbars.dds -set colorspace ycbcr -colorspace rgb newfile.png

I've also tried:

convert colorbars.dds -set colorspace ycbcra -colorspace rgb newfile.png

Re: dds to png conversion colors wrong

Posted: 2016-04-28T14:04:46-07:00
by videomike99
I'm not sure what the original colorspace is, so I've tried just about every one, as well as omitting the value and going with the default as well.

Re: dds to png conversion colors wrong

Posted: 2016-04-28T14:21:14-07:00
by snibgo
After the image has been read, the colorspace is similar to YCbCr, but in the order CbYCr so we need to swap the first two channels.

Code: Select all

convert colorbars.dds -separate -swap 0,1 -combine -set colorspace YCbCr -colorspace sRGB x2.png
The result is close to the required colour chart, but not exactly the same.

Re: dds to png conversion colors wrong

Posted: 2016-04-28T14:36:30-07:00
by videomike99
That's great...now it just seems like a gamma issue maybe...

Re: dds to png conversion colors wrong

Posted: 2016-04-28T14:48:36-07:00
by snibgo
Sadly, no, it isn't just a gamma issue. My result gives "gray" patches that have slightly different values in the three channels.

Re: dds to png conversion colors wrong

Posted: 2016-04-28T14:56:10-07:00
by fmw42
snibgo wrote:After the image has been read, the colorspace is similar to YCbCr, but in the order CbYCr so we need to swap the first two channels.
snibgo, I am just curious. I do not know DDS image format, so I am curious how you knew the channels were swapped. Are the Cb and Cr channels much different from the Y channel in values? Or was it just a guess on the way the colors seemed swapped?

Re: dds to png conversion colors wrong

Posted: 2016-04-28T15:32:30-07:00
by snibgo
I know nothing about DDS.

After a simple "convert in.dds out.tiff" conversion, I looked at the pixel values in the bars that should be varying lightnesses of gray, using an image editor with eyedropper. The first and last channels were around 50%, with the middle value varying. So the middle channel seemed to be luminance or Y. I tried all the Y?? colorspaces and YCbCr seemed the closest fit.

I don't know if IM's DDS reader does any colorspace conversion, or re-arrangement of channels. dds.c is quite complex.

Re: dds to png conversion colors wrong

Posted: 2016-04-28T16:02:16-07:00
by fmw42
snibgo,

You said that you used

Code: Select all

convert colorbars.dds -separate -swap 0,1 -combine -set colorspace YCbCr -colorspace sRGB x2.png
and that did not quite work out. Had you tried swapping Cb and Cr along with moving Y to the middle channel, i.e.

Code: Select all

convert colorbars.dds -separate -swap 1,2 -combine -set colorspace YCbCr -colorspace sRGB x2.png
If so, was that better or worse?

Re: dds to png conversion colors wrong

Posted: 2016-04-28T16:15:27-07:00
by snibgo
Of the possible arrangement of channels Y-Cb-Cr, the one that fits best is Cb-Y-Cr. All other arrangements are clearly worse.

@videomike99: What software created colorbars.dds, or where did you get it from?