by damned truths

submit your photo

Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×

In my work I am dealing with *.CR2 raw images taken by a Canon DSLR in raw mode. When I read about the format here, I was surprised to find that it has 4 TIFF IFDs which contain a) Original Size JPEG Image b) Thumbnail JPEG image c) Uncompressed RGB data d) Lossless JPEG image.

My impression until now was any camera captured RAW image file would have Raw Bayer Data i.e. R,Gr,B,Gb kind of bayer data, and some EXIF data about camera capture settings etc.

But after reading this CR2 specification I am slightly confused as to how can it have a RGB data or even surprisingly JPEG data. This seems to be the data after demosaicing(obtaining the missing R/G/B pixel data for the original sensor Bayer pattern). If thats the case I would not consider *.CR2 as "truly raw" data. It has done demosaicing before dumping the socalled raw file.

Am I missing something?

Does any other Camera Raw formats(e.g. Nikon - *.NEF, Kodac - *.kdc, Pentax - *.ptx/pef,...) have real raw bayer data without any processing done?

share|improve this question
The page you link to says that it contains the Bayer pattern, so yes, it has the Bayer pattern. –  user13599 Nov 19 '12 at 3:35

2 Answers 2

up vote 10 down vote accepted

I think you are most definitely missing something. Consider: JPG is used to store (and usually compress, lossy) images. Any image. What is an image? It is a great big bundle of pixels, when all is said and done.

The output from the camera sensor is a great big bundle of pixels, too. They just happen not to be full-colour RGB pixels, they are monochrome pixels - whether any individual pixel represents R G or B depends on its location on the image sensor, which is known. But their monochrome, colour-given-by-position nature does not mean that they cannot be usefully stored in the JPG way. A bundle of pixels is a bundle of pixels, and why reinvent the wheel?

Look more closely at the document. "So with a BAYER grid of RG/GB, the even rows has interleaved HuffCode/Diff data for ...RGRGRG..., while the odd rows it is ...GBGBGB...". So, the raw Bayer output is stored in a JPG format. Lossless, it is stated (otherwise we'd have a problem!) and presumably in more than 8 bits' depth. You have too cook this quite a lot to get a useful photo from it.

The other JPG images are used for in-camera preview, histogram and such. It makes good sense to cook these once and for all as the image is taken, rather than having to do it on the fly each and every time you want to look at them. This also means that the computer can fish these out for thumbnail purposes once you unload the camera into the PC.

* I can't add a comment for some reason, so this goes here: Goldenmean, what makes you think that there is a problem that you don't have full RGB info for each pixel? Assuming that you are creating a RAW format and have a measurement of 128 from a "red" sensor cell; you can either choose to store this as 128,0,0 or 128,128,128 or, of you are feeling clever, 128,"data from next cell", "data from the cell after that" to save some space. Doesn't matter really. It's the RAW converter's job to keep track of this (though I'm sure the programmers would appreciate it if you documented how you chose to store your sensor data) and make an actual picture from it.

share|improve this answer
The lossy JPG format we're all familiar with is apparently quite different from the confusingly named "Lossless JPEG" scheme used in these raw files. –  Lyman Enders Knowles Apr 1 '11 at 17:38
@Lyman: Yes, it is. It's also used in DNG for example, se more: –  Guffa Apr 1 '11 at 20:16
I understand - 'everything being pixels thing', and the 'lossless JPEG codec as well' but still questions remains, how can it have 3 components for each pixels stored in the raw. Sensor doesnt give a triplet for each physical pixel, but it gives only one of the 3(R,G,or B), not all 3 which the formats seems to be storing for eack pixel.. Thats the qn. –  goldenmean Apr 4 '11 at 9:17
Thanks for the answer edit/comment. –  goldenmean Apr 4 '11 at 14:22

The DNG contains Lossless grayscale JPG with resolution 4 times higher than "normal" color jpg file. Is it more clear now?

What is the problem in placing 3 types of black balls in a basked that is meant to hold 3 colored balls?

In the JPG file there are no colors, there are just numbers, as in any other file format. And they use JPG because it is easier to encode it in this way, because the camera processor is already made to create such files.

They would probably write the matrix data into zip, rar, flac, or any other lossless format pretty much the same way. But that would require a bunch of algorithms added into the software of the camera, that are not needed.

share|improve this answer
I'm confused by your explanation. the link is no longer working, but the OP indicates that there are TIFF files. If the camera can produce TIFF files, then why does it need to encode raw data into JPG? Lossless JPG means no data lost in compression, but that doesn't necessarily mean that the conversion from raw matrix data into JPG doesn't transform or lose information in some way, does it? –  MikeW May 21 at 23:40

Your Answer


