About how large is a RAW file?

Started Feb 20, 2013 | Discussions
Paden Junior Member • Posts: 27
About how large is a RAW file?

Hey guys. How large are RAW files compared to maximum quality. For a 16mp DSLR?

Mark_A
Mark_A Forum Pro • Posts: 16,447
Re: About how large is a RAW file?

Paden wrote:

Hey guys. How large are RAW files compared to maximum quality. For a 16mp DSLR?

Check the dpreview review for your choice of camera it usually specifies the filesize.

Mark

BertIverson Veteran Member • Posts: 4,224
Re: About how large is a RAW file?

Paden wrote:

Hey guys. How large are RAW files compared to maximum quality. For a 16mp DSLR?

Mark_A's answer sound good to me.
However, in theory, assuming 12bit RAW, size should be in the vicinity of 1.5 times 16MP less whatever compression is applied. My 20MP camera has RAWs of 20MB and my 12MP camera has 12MB RAW's.

Bert

 BertIverson's gear list:BertIverson's gear list
Sony RX10 IV +5 more
GordonBGood Veteran Member • Posts: 6,312
Re: About how large is a RAW file?

Mark_A wrote:

Paden wrote:

Hey guys. How large are RAW files compared to maximum quality. For a 16mp DSLR?

Check the dpreview review for your choice of camera it usually specifies the filesize.

Paden, as Mark says this depends on the camera make and model as there are many variables.  Even JPEG size is a variable as cameras have different amounts of JPEG compression, with a top quality JPEG image file for a 16 Megapixel camera likely being between about six and sixteen Megabytes.  Different cameras have very different raw file formats with most also containing a full size JPEG preview of a few Megabytes plus the raw data and metadata and the raw data may be stored in different ways:  as uncompressed RGB data per pixel which could take up to 96 Megabytes, as uncompressed Bayer data (one colour per pixel) at one third of that, as byte packed 12-bit depth data which will be 75% of the pure uncompressed size, as loss-less compressed 12 bit data which might be about 50% of the pure uncompressed size, as loss-less compressed 14 bit data which might be at least 25% bigger than the 12 bit depth version using similar compression, to various forms of "virtually loss-less" compression which will be somewhat smaller than the "pure" loss-less version - I think you can get the idea.

In general terms, a raw file is often two to three times the byte size of an "adequate" high quality JPEG of the same image and as little as about the same byte size of a "super fine" JPEG, but there are exceptions such as the Sigma camera which have raw files (RGB) about six to eight times the size of the JPEG's.

Regards, GordonBGood

OP Paden Junior Member • Posts: 27
Re: About how large is a RAW file?

Thanks guys!

brucet
brucet Veteran Member • Posts: 3,922
Re: About how large is a RAW file?

I have a D7000. I shoot Raw 14 bit files. Depending on content they are between 18 and 21 meg. Into 16 bit Tiffs they come out as 96 meg.

Regards

 brucet's gear list:brucet's gear list
Nikon D7100 Nikon AF-S DX Nikkor 35mm F1.8G Nikon AF-S Nikkor 50mm F1.8G Nikon AF-S DX Nikkor 18-105mm F3.5-5.6G ED VR Tokina AT-X Pro 12-24mm f/4 DX II
tkbslc Forum Pro • Posts: 16,770
check the manual for the camera

If you are looking at a certain camera, download the manual from their www site.  It will list file sizes.   It really can vary depending on who makes the camera.

hotdog321
hotdog321 Forum Pro • Posts: 21,044
Re: About how large is a RAW file?

I assume you are shopping for memory cards or storage devices. As everyone said, it varies a bit according to light, subject and ISO, but for my 21.1 megapixel camera (daylight, ISO 200) RAW = 28 meg; jpeg = 7 meg. Roughly.

 hotdog321's gear list:hotdog321's gear list
Canon EOS 5D Mark IV Canon EF 16-35mm F4L IS USM Canon EF 24-70mm F2.8L II USM Canon EF 70-200mm F2.8L IS II USM Canon EF 11-24mm F4L +3 more
scorrpio
scorrpio Veteran Member • Posts: 3,595
Re: About how large is a RAW file?

On Canon 60D (18 mp), full size RAW is about 21-26MB.   The data is losslessly compressed, hence the variance.   Highest quality OOC Jpegs are 4-6MB

John1940
John1940 Senior Member • Posts: 2,820
RAW file size with lossless compression

Paden wrote:

Hey guys. How large are RAW files compared to maximum quality. For a 16mp DSLR?

If no compression were used for a 20 MP camera raw file that has 14-bit analog-to-digital conversion (ADC) of each pixel location voltage then the file size would be 40 MB. The reason is that two bytes (16 bits) would be needed in memory in order to respect byte boundaries.In today’s computers that’s not much of a penalty but it is in a camera and transmitting such a large file size to a memory card takes more time.

There is a lot of useless data and redundant data in those two bytes in a typical image. First, two bits are not used at all. Next, many of the voltages (in whatever units are used) are small while others are large. Clipped ones show up as all binary ones (or 2^14, which is 16384 voltage units). If there is no voltage, the number can be written as 1 instead of 00000000000001 in binary. In other words, leading edge zeros are not needed. Similarly, three units is 11, and so on. The largest number (before leading ed leading edge zeros are deleted) is 0011111111111111, so there is not much to be compressed there.

There are more opportunities for compression as well. For example, one can establish a par number, such as used in golf score card or current rankings after each round. Instead of showing the whole number of strokes it’s better to show scores relative to par. In the camera, the par will increase if you crank up the ISO. All of these tricks are totally lossless. They save memory space and reduce transmission time. Once the data is in the computer and ready for alteration the files are uncompressed.

The following shows compression of part of President Kennedy’s famous speech in the first two chapters.

http://www.howstuffworks.com/file-compression.htm

Want to test my reasoning? I just tried it but it was admittedly not a very scientific test. First, I took a raw image (not raw+jpeg) in manual mode with ISO 100 and exposed approximately correctly in a bright situation. Then I left settings the same and took a picture of a dark object with relatively little color variation. With my 18 MP 600D, the first raw file was 22.3 MB and the second was 20.1 MB. I had to expose the second picture even more because the light was too dim. Otherwise there might have been even a smaller raw file size with more useless leading edge zeroes (out of the DAC) that were eliminated by compression. With no compression, the 600D raw file size would be about 36 MB.

-- hide signature --

John1940

 John1940's gear list:John1940's gear list
Sigma DP3 Merrill
GordonBGood Veteran Member • Posts: 6,312
Re: RAW file size with lossless compression

John1940 wrote:

Paden wrote:

Hey guys. How large are RAW files compared to maximum quality. For a 16mp DSLR?

John, I've taken the liberty of paraphrasing the following for conciseness:

If no compression were used, there would be up to two bytes used per photosite encoding).

There is a lot of useless data and redundant data in those two bytes in a typical image.

There are many opportunities for compression, such as encoding changes in value rather than absolute levels or using codes that are only as long as necessary to express the values.

The following shows compression of part of President Kennedy’s famous speech in the first two chapters.

http://www.howstuffworks.com/file-compression.htm

Want to test my reasoning although not very scientifically?   First, I took a raw image (not raw+jpeg) in manual mode with ISO 100 and exposed approximately correctly in a bright situation. Then I left settings the same and took a picture of a dark object with relatively little color variation. With my 18 MP 600D, the first raw file was 22.3 MB and the second was 20.1 MB.  With no compression, the 600D raw file size would be about 36 MB.

John, although the principles of compression you outline above are correct, many of them do not apply to loss-less compression of raw files as they are a unique type of data.  For instance, applying a straight WinZip type of compression (as per the above link) to most raw image files does very little in reducing file sizes as it ignores that the raw data is actually interleaved values from individual data channels, with two green, one red and one blue channel, and it also ignores that raw data has unique variations to the magnitude of the random component.

Raw data compression does encode the relative change in readings but in order to be effective it needs to be applied per channel so in raw encoding it encodes the change in value referenced to the the immediately adjacent same channel photosite to the left (or directly above for the case of a new row) for the sensor in landscape orientation.  Thus, the whole image would theoretically contain nothing but a series of zeros for an image of a fixed colour other than for the first four readings at the start of the first row and columns for each of the four channels.

This then works in conjunction with Huffman encoding, which assigns particular shorter binary codes to represent the most frequently occurring values and longer codes to less frequent values.  Thus, for a Huffman scheme that say assigned a two bit code to represent zero and longer codes to represent the less frequently occurring larger delta values (with some codes possibly being longer than 14 bits), the above constant colour raw image could be compressed to about 4.5 Megabytes for an 18 Megapixel raw image even though the raw bit depth is 14 bits.

Unfortunately, the realities of raw sensor output interfere with this ideal encoding, even for black frames - the inside of lens cap images:  sensors have noise so that the delta values are almost never zero and that noise is larger the brighter the output, which is the effect of statistical variation of the arrival of photons.  This means that even for the lowest ISO senstivity for your Canon 600D, the average delta value for a constant black level is at least an average of about four levels, and for a constant very bright level has an average delta value of about 80 levels, expressed in therms of a 14-bit range.  Thus a zero delta is rarely encoded.

In addition, different images will have different histograms meaning that the frequencies of occurrence of various delta values will vary depending on the image.  Also, the calculation of new Huffman frequency encoding tables requires time and computer resources due to requiring two passes through the data to be encoded.  Thus, camera manufacturers calculate these tables once for an average image and those are the values that are applied in compression.  Typically, this results in an average of about eight-bit codes being used for 14-bit raw bit depths for very dark images, which explains the file sizes that you saw and why they changed by such a small percentage in spite of there being much less colour variation in the second case.

Part of the reason that even "lens cap shots" are so large for Canon raw image files  is that  at no point is the noise ever less than the least significant two bits for a 14 bit depth meaning that the least significant two bits are essentially useless as they carry random information that could just as easily be injected into the image on decoding of a 12 bit raw depth.  Due to this, every Canon raw file carries at least 4.5 Megabytes or more of excess baggage that adds nothing to the image quality even for the darkest colours at the lowest ISO sensitivities.

There are schemes such as Nikon's "virtually loss-less" raw compression that essentially vary the retained bit depth dependent on the brightness of the colour so as to encode less of this random data, but these schemes have never been completely developed to their maximum potential as different curves and Huffman encoding tables should be used for each ISO sensitivity; in this way there would be no need for higher ISO images to be so much larger than lower ISO ones and in fact could be smaller since there is actually less non-random data in them.

So that is how the most common form of raw loss-less compression works, for your reference.

Regards, GordonBGood

Keyboard shortcuts:
FForum MMy threads