Using ImageMagick to convert a 4:2:2 YCrCb raw image to something viewable
Some electronic imaging system dumped a 4:2:2 YCbCr raw image into a file. It’s a debug output. Now I wanted to see this image. GIMP doesn’t import that format. ImageMagick had the solution. It was as simple as
convert -size 800x600 pal:ImageOut.raw ImageOut.bmp
I don’t know why they picked the codename “pal” to represent 4:2:2 format (maybe because of ITU-R BT.601?) , but it did the job. Ah, they call it “YUV” and not “YCbCr”, but it was really close enough for me.
For a list of supported formats:
convert -list format
Reader Comments
Since this entry rates so high on Google, I thought I’d put in a better answer.
The generic format is “yuv”. So:
convert -size 800x600 -depth 8 yuv:image.raw image.png
You will need to provide:
Bits per pixel (-depth 8)
The Y:U:V ratio (-sample 4:2:2)
The relative location of the various bits of information (read about the -interlace option).
So, if we have a 4:2:0 image with the Y plane followed by the Cb followed by the Cr planes:
convert -size 800x600 -depth -sample 4:2:0 -interlace plane 8 yuv:image.raw image.png
Shachar
One correction to the other comment: It’s not “-sample 4:2:0″, but “-sampling-factor 4:2:0″.
You have slipped the “sample” and “interlace” fields in the middle of the “-depth 8″ part, thereby separating the “-depth” from the “8″