What is a RAW file technically, and how is it different from JPEG or bitmap images?

Asked 7/26/2010

3 views

2 answers

0

Technically speaking, what does a camera RAW file contain? How is the data stored, and how does RAW differ from a JPEG beyond just compression? Also, in what sense is RAW different from a bitmap/raster image file? I'm looking for the technical distinction rather than a pros/cons comparison.

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

Photography Stack Exchange contributor

16y ago

2 Answers

124

RAW is data that is extracted from the camera at an earlier stage of processing.

This allows further processing to be carried out later on a computer at will. Notably, it avoids the lossy processing steps of demosaicing, sharpening/noise reduction, and JPEG compression being permanently applied to the resulting image file before it leaves the camera.

When you take a photo:

Here's what happens when you take a photo, and at what stages of processing the RAW and JPEG images are extracted.

  1. Bayer filter

    The shutter opens and light enters the camera. The light is filtered through a bayer color filter so each pixel on the sensor only receives either red, green or blue light. This is required because without it the sensor is monochrome.

  2. Sensor

    The light hits the sensor (often through tiny microlenses which help gather more light into the sensitive part of the pixel). It's then converted into millions of analogue impulses, each one corresponding to a pixel.

  3. Analogue to digital conversion

    The analogue impulses are amplified to the correct amount according to the sensitivity (ISO rating) selected and then they are converted into digital values using an analogue to digital converter, at a certain bit depth. After this stage you have millions of (typically 12- or 14-bit) digital values in a stream.

    Note that the method for analogue to digital conversion is very different in CMOS and CCD sensors. For instance, a CMOS sensor contains a transistor in each pixel to assist with this, but suffice to say that at the end, you still get a bunch of digital values.

  4. Black level adjustment

    The camera needs to determine the correct black level, since the sensor will not necessarily return zero for pixels that are black. For example, the ambient heat of the sensor may cause some signal. Correcting for this is often done by reading sensor data from some edge pixels which are permanently covered so light can't reach them. Then it subtracts an appropriate value from the other results. It may do other corrections on the digital data - it may try to reduce some types of noise, such as background noise caused by the sensor.

    Sometimes the digital values may then further be multiplied or divided in order to reach the right sensitivity (ISO) value, if you are using an ISO value that your sensor doesn't do natively.

    This is where RAW data is extracted.

    If you shoot RAW, none of the steps below here are permanently applied to the image file as it comes out of your camera, allowing you to apply them at will in your RAW software instead.

  5. Demosaicing

    Each value is in fact either a red, green or blue value. However, you need each pixel to have all three colours - red, green and blue - for the final image. Therefore, a demosaicing algorithm has to guess the other two colour parts for each pixels, and it does this based on knowledge of surrounding pixels. There are a variety of different demosaicing algorithms with varying qualities, and it is a lossy process. If this occurs in-camera, then you are stuck with the camera's built-in algorithm.

  6. Colour space conversion

    Red, green and blue in the Bayer filter are not necessarily the same hue as red, green and blue in the standard sRGB colour space. The camera then does colour correction to convert the colours into the desired colour space, which is usually sRGB.

  7. White balance

    White balance correction is applied to correct for different colour temperatures of light sources while taking the picture.

  8. Gamma correction

    Gamma correction is applied which converts from the linear values to gamma corrected values as required by digital image files. This correction is not a straight gamma correction; a contrast curve is applied to ensure that highlights and blacks curve off nicely giving it a nice film-like appearance.

  9. Sharpening and noise reduction

    An appropriate amount of sharpening and noise reduction are applied to enhance the image and try to suppress annoying noise. There are different sharpening and noise reduction algorithms, and this is a lossy procedure. If this is done in-camera, then you are stuck with whatever sharpening and noise reduction was applied by the camera.

  10. JPEG compression

    The resulting image data is compressed as a JPEG. This is also, obviously, a lossy procedure.

    This is where a JPEG file would be generated.

More about the RAW format

To create the RAW file, raw data from steps 1 to 4 above is assembled into a file format, which is usually a proprietary, manufacturer-specific file format based on the TIFF format. The data is sometimes compressed using a simple lossless compression algorithm and sometimes part of it is also encrypted.

Within the RAW file, the camera embeds a whole lot of metadata, with all the information necessary to do the extra processing steps later according to the camera's settings. This includes information like what white balance, sharpening and contrast settings are selected in the camera. RAW software can then choose to follow this advice or ignore it.

The camera also embeds a JPEG file into the RAW file, which it can then use when playing back the image in the in-camera "play" mode. This embedded JPEG adds a little to the size of RAW file but it means the camera doesn't have to apply all that processing every time the image is viewed in play mode. RAW processing software on computers largely ignores the embedded JPEG, though some software may use it for a fast preview mode or for generating fast thumbnails. It is generally a fairly low quality JPEG, good enough for previewing only.

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

user3422

15y ago

0

AI Answer

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

A RAW file is the camera sensor’s captured data saved at an earlier stage of processing than a JPEG. In most cameras, each sensor site records only one color component (through a Bayer filter), so the RAW file usually contains those per-pixel sensor readings plus metadata such as camera settings, sensor information, EXIF data, and often a small embedded JPEG preview.

Unlike JPEG, RAW is usually not a finished, standard image ready for direct display. It typically has not yet had key processing permanently applied, such as demosaicing, white balance, sharpening, noise reduction, color rendering, and JPEG compression. A JPEG is derived from that sensor data after the camera processes it into a viewable image and compresses it using a standardized lossy format.

Compared with a bitmap/raster image, RAW is different because a bitmap normally stores already-interpreted pixel values for the final image (for example RGB values at each pixel). RAW generally stores the original sensor measurements before they are converted into full-color image pixels. Also, there is no single universal RAW format—manufacturers use their own variants.

UniqueBot

AI

16y ago

Your Answer