Page 1 of 1

Decoding a JPG to readable YCbCr hex data

Posted: 2017-05-31T09:05:05-07:00
by skitchjr
Hi,

I'm trying to verify a JPEG Codec, and running into the following problem: I ultimately need to decode the original .jpg image and convert the output to some sort of readable YCC data.

First, I attempted to use the open source djpeg, but whether I'm outputting .bmp, .gif, et al, it's always in the RGB colorspace.

Next, I used ImageMagick to convert the .jpg straight to a .miff file in the YCbCr colorspace:
% convert -colorspace ycbcr testImage.jpg testImage.miff

The output (.miff file) identifies as YCC, but how can I actually extract the image data from this file?

I attempted to use the following to make it more readable:
% xxd -i testImage.miff testImage_miff.txt
However, I don't know how to parse through the header information like I normally would with a .jpg or .bmp file.

Thanks for your help!

Re: Decoding a JPG to readable YCbCr hex data

Posted: 2017-05-31T09:16:48-07:00
by fmw42
convert to -colorspace YCbCr and output to txt: and redirect that to a file. You can then review or process the file since it is readable in any text editor.

Code: Select all

convert input.jpg -colorspace YCbCr txt:- > textfile.txt
See http://www.imagemagick.org/Usage/files/#txt

Example:

Code: Select all

convert rose: -colorspace YCbCr txt:-

# ImageMagick pixel enumeration: 70,46,65535,ycbcr
0,0: (12097,32467,32938)  #2F7E80  ycbcr(47,126,128)
1,0: (12431,32424,33066)  #307E81  ycbcr(48,126,129)
2,0: (13069,32209,33344)  #337D82  ycbcr(51,125,130)
3,0: (13344,31908,33514)  #347C82  ycbcr(52,124,130)
4,0: (13468,31693,33792)  #347B83  ycbcr(52,123,131)
5,0: (13241,31821,33771)  #347C83  ycbcr(52,124,131)
6,0: (12862,32035,33858)  #327D84  ycbcr(50,125,132)
7,0: (13119,32035,33858)  #337D84  ycbcr(51,125,132)
8,0: (12862,32035,33858)  #327D84  ycbcr(50,125,132)
...

Re: Decoding a JPG to readable YCbCr hex data

Posted: 2017-05-31T10:41:44-07:00
by skitchjr
Thank you!

That did the trick. I should be able to easily parse out what I need from that output.