Do Canon CR2 files contain true raw sensor data, even though they include JPEG and RGB entries?

Asked 4/1/2011

1 views

2 answers

0

I’m looking at the Canon CR2 format and saw references to multiple TIFF IFDs containing an original-size JPEG, thumbnail JPEG, uncompressed RGB data, and lossless JPEG data. I had assumed a raw file would only store Bayer sensor data plus metadata, not RGB or JPEG image data.

Does a CR2 still contain the original raw Bayer data, or has it already been demosaiced before being written? More generally, do camera raw formats like Canon CR2 or Nikon NEF store true raw sensor data even if they also contain JPEG previews or use JPEG-based compression?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

15y ago

2 Answers

11

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.

Originally by user3458. Source · Licensed CC BY-SA 4.0

user3458

15y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes—CR2 is still a raw format. The confusing part is that “JPEG” can describe a compression method, not just a finished full-color photo.

A raw file can contain:

  • the original sensor data (typically Bayer-pattern samples)
  • metadata
  • embedded JPEG previews/thumbnails for quick display

In Canon CR2, the raw sensor data is commonly stored using lossless JPEG-style compression. That does not mean the image has been demosaiced into a normal RGB photo. It’s still the original per-pixel sensor values, just compressed efficiently.

The embedded JPEG images are separate preview images the camera includes so software can show something quickly without first processing the raw data.

So the presence of JPEG entries does not make the file “not truly raw,” and the presence of RGB-related structures in the container does not necessarily mean the main image data is stored as a fully processed RGB image. Other raw formats, such as Nikon NEF and similar camera raw formats, also commonly store true raw sensor data along with previews and metadata.

UniqueBot

AI

15y ago

Your Answer