How to get Raw data from CR2 format. page6 - IFD3 and Raw data

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

> > >



3.6 IFD3

IFD3 starts from the address 0x0000 B6A6.
Below is the result of parsing IFD1 by exiftool (command option -v3)


  + [IFD3 directory with 7 entries]
  | 0)  Compression = 6
  |     - Tag 0x0103 (2 bytes, int16u[1]):
  |         b6b0: 06 00                                           [..]
  | 1)  StripOffsets = 2413920
  |     - Tag 0x0111 (4 bytes, int32u[1]):
  |         b6bc: 60 d5 24 00                                     [`.$.]
  | 2)  StripByteCounts = 16908088
  |     - Tag 0x0117 (4 bytes, int32u[1]):
  |         b6c8: 38 ff 01 01                                     [8...]
  | 3)  Exif_0xc5d8 = 1
  |     - Tag 0xc5d8 (4 bytes, int32u[1]):
  |         b6d4: 01 00 00 00                                     [....]
  | 4)  Exif_0xc5e0 = 3
  |     - Tag 0xc5e0 (4 bytes, int32u[1]):
  |         b6e0: 03 00 00 00                                     [....]
  | 5)  RawImageSegmentation = 2 1728 1888
  |     - Tag 0xc640 (6 bytes, int16u[3]):
  |         b700: 02 00 c0 06 60 07                               [....`.]
  | 6)  Exif_0xc6c5 = 1
  |     - Tag 0xc6c5 (4 bytes, int32u[1]):
  |         b6f8: 01 00 00 00                                     [....]

This IFD has the address to Raw data.
In the sample, raw data starts at the address 0x0024 D560 (entry #1) and the length is 16,908,088 byte (#2).
This raw data is encoded by 16bit gray scale Lossless JPEG (ITU-T T.81).

However, this raw data is not stored by actual sensor layout.
The three values in tag 0xC640 called "RawImageSegmentation" in exiftool ( or "CR2_clice" in "Understanding...") requires to encode or decode.

Now let the three values be A,B and C.
The sensor width equals A times B pixel width and C pixel width.
sensorWidth = A x B + C

In the sample, values are 2, 1728 and 1888, and we can get three areas which each width are 1728,1728 and 1888. Please see the following figure.



Then, we store the #0 area data sequentially into the image data array for lossless compress like following figure.



After storing #0, we store #1 and #2 area data as same.
The image data array is compressed into 16bit gray scale Lossless JPEG format and is stored in the address 0x0024 D560

In decoding, you should do the reverse.


next page : Decoding Lossless JPEG

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