Why are image file sizes often close to a camera’s megapixel count?
Asked 11/28/2016
7 views
2 answers
0
If a camera has a 1-megapixel sensor, it has about 1,000,000 photosites. If each recorded only 8 bits, that would seem to be about 1 MB of data. But many camera sensors record 12-bit or 14-bit raw data, so I would expect the files to be much larger. Why do image files from cameras often end up with sizes that are still fairly close to the camera’s megapixel count in megabytes?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
9y ago
2 Answers
6
To start with, the sensor doesn't output any color. Each pixel only records a single value: how much light struck the sensor. The number of bits determines how fine the steps between each brightness level can be. That's why a 12-bit or 14-bit file can record much finer gradations of lightness than an 8-bit file.
But raw files are also compressed, just normally in a lossless manner. If there are fewer unique values from all of a sensor's pixel wells the data can be compressed smaller than if there are more of the 2^12 or 2^14 possible tonal values for each pixel. Raw files from my 24MP camera generally run anywhere from 22MB to 29MB each depending on the content. Some cameras even use lossy compression to store raw files.
The way color is derived is by filtering each pixel for one of three colors: Red, Green, and Blue. But all that is measured on the other side of the filter by that pixel well is how much (i.e. how bright) light was allowed to pass through the filter. The filters still each let some light through that are colors other than the exact color of the filter. The further a color is from the color of the filter, though, the less amount of that color falling on the filter will make it through and be recorded by the pixel well. Some green gets past both the red and blue filters. Some red and blue get past the green filter. By comparing the difference in brightness of adjacent and surrounding pixels filtered for different colors the process known as debayering or demosaicing can interpolate an R, G, and B value for each pixel. Only after the color has been interpolated will the value of each color for each pixel be stated using 8-bits per color for 24-bits per pixel. In the case of JPEG this data will also be compressed. Basically JPEG designates which pixels are all the same exact combination of all of the different combinations of R,G, & B contained in the image. That is why images that are mostly the same uniform colors can be compressed smaller than images that have almost every possible combination of colors.
If you output a 28-30MB raw file from a 24MP camera after debayering it into a 16-bit TIFF the file will very likely be over 100MB in size because it is recording 16-bits for each of three colors for each pixel.
Originally by user15871. Source · Licensed CC BY-SA 4.0
user15871
9y ago
0
Generated from our catalog & community — verify before relying on it.
Because megapixels and file size are related, but not in a simple 1 pixel = 1 byte way.
A camera sensor’s photosites do not directly record full RGB color. Each photosite records one brightness value, usually at 12 or 14 bits in a raw file. So uncompressed raw data is typically about 1.5 bytes per pixel (12-bit) or 1.75 bytes per pixel (14-bit), not 1 byte.
The reason files often end up near the megapixel count in MB is compression. Raw files are usually compressed, often losslessly, so the stored file can be significantly smaller than the uncompressed data. The exact size varies with image content, which is why files from the same camera are not always identical in size.
If the file is JPEG, it is compressed even more aggressively. JPEG is also 8 bits per color channel after demosaicing into RGB, but compression has a much bigger effect on file size than the sensor bit depth alone.
Also, “megapixel” is about 1,000,000 pixels, while MB in storage is often treated as 2^20 bytes, so the units are not exactly the same.
Recommended products
UniqueBot
AI9y ago
Your Answer
Related Questions
How do megapixels relate to maximum print size?
Why can photos with the same resolution and format have very different file sizes?
Why is a 16-bit TIFF much larger than the original RAW file?
Why would someone convert a RAW file to an 8-bit TIFF for Photoshop retouching?
Does a camera’s megapixel count refer to pixels or color-filtered photosites?