How to get Raw data from CR2 format.

since:Aug 31,2014
last update:Sep 6,2014
Japanese Page
next page


top > photograph and camera > How to get Raw data from CR2 format. page1

0. Introduction

To get good astronomical photos, we need to process Raw image data. Therefore I wrote the application called "RStacker" to process dark subtraction and/or flat fielding for uncompressed DNG Raw image format.
The other day I thought I would like to improve the convenience of this application, and added the logic to support CR2 format which is Raw image format for Canon digital camera.
This document describes that how to get CR2 Raw image data with actual example, through my application development.

0.1 disclaimer

This document is NO WARRANTY.

1. What is Raw image format?

Raw image format is the format which is recorded actual values by digital camera sensor.
Although jpeg format which is most popular viewable format can have 8 bit range value (from 0 to 255) per pixel and each color, Digital camera sensor can generally get much range value such as 12bit, 14bit and so on. Therefore digital camera reduces to 8 bit range in jpeg image output.
This would cause some disadvantages when we postprocess the image like to change contrast ,color balance or etc.

In addition, These sensor like CMOS or CCD can get the wide range wave length ray from UV to IR, they cannot identify the color by themselves. Therefore, almost sensor have color filter array in front of themselves, and these called Bayer filter. Then, by interpolating the missing color information, we can get the viewable format image.

However, some processing such as removing the hot pixel takes disadvantage after interpolating, so processing Raw data is effective .

1.1 Type of Raw image format

Major Raw image format is as follows:

Major Raw image format
formulatorformat namenote
CanonCR2
NikonNEF
SonyARW
FujiRAF
AdobeDNGSpecification is public.

1.2 CR2 format

Like other raw image format, specification of CR2 format is not public too. Therefore I refered the result of analysis by volunteers.
In those most valuable site is below.

Understanding What is stored in a Canon RAW .CR2 file, How and Why

I think you can roughly understand the specification of CR2 format in that site.

In addition you need some other information.

You need to understand TIFF because the structure (encoding rule etc) of CR2 format is TIFF.
Specification of TIFF exists in below URL of adobe site.
http://partners.adobe.com/public/developer/tiff/index.html

You also need to understand Lossless JPEG in ITU-T T.81 because Raw data in CR2 format is compressed by this encoding rule.


Note: valuable tools for understanding CR2 format

Exiftool : Parser

JpegAnalyzer Plus (Japanese only) : Parser

Stirling (Japanese only) : Binary Editor

Adobe DNG Converter : Converter into DNG format. It is valuable for checking raw data.


Next page: Structure of CR2 format

[1] [2] [3] [4] [5] [6] [7] [8] [9] next page