Want to take your phone photography to another level? Perhaps you've heard people talking about "shooting RAW". What are RAW photos, and how can you take advantage of them on an Android phone?
What is a RAW photo?
How does a camera convert light into a image file (such as a JPG)? It turns out that this is based on how our eyes see. We need to grok both of these processes to understand exactly what a RAW file is, and how we can take better photos with it.
How does the eye see?
Light is a wave (that's not the whole story, but it will suffice for our purposes). Like all waves, it can have different wavelengths (just like waves on the surface of a pond can have different distances between them). The color of a light wave is determined by it's wavelength.
If (unlike me) you paid attention during biology class, you may recall that the eye contains three types of receptor cells that detect different colors of light. These colors are distributed at the ends and middle of the spectrum, allowing us to detect red, green, and blue.
Our brain then mixes these three colors up allowing us to see intermediate colors. Just like how a painter, if you give them three paints in these three colors, would be able to combine them to create any other color.
How does a digital camera make an image?
Because our eyes see in red, green, and blue, every digital device recreates images using these three colors. Consequently, the digital sensors found in cameras and scanners are also designed to detect these three colors.
However the tiny light detectors used in these digital sensors cannot tell the difference between different colors of light. Instead, they just detect when a wave of light of any wavelength hits the detector. So, how can we use these to see color?
The answer is to stick red, green, or blue filters in front of different detectors. A red filter will only let red light through, and so the light detector behind it will only detect red wavelengths. The same happens for the other two colors.
Camera sensors are made up of quilt-like arrays of these different colored filters.
The sensor records the amount of red, green, or blue light waves hitting each light detector in the array. These intensities of individual colors can then be saved as a RAW file (so-called because it is the raw sensor data).
From RAW to JPG (or PNG/TIFF/etc.)
If you look at the image files on your phone or computer, most of them will be stored as JPG files. Another common image file format is PNG.
Whereas RAW files record only the intensity of a single color at each point, JPG and related image files record the value of all three colors in each pixel. In other words, each pixel in a JPG can be any color (not just red, green or blue).
To make a JPG file from the RAW sensor data, we have to combine the patchwork quilt of sensor colors into pixels of any color (just like the artist mixing his paints). This process is called demosaicing. If your phone or camera saves photos as JPGs, then this demosaicing is automatically done for you.
Simple, you might think. Except... how do you know what proportions to mix the three colors in?
The first advantage of RAW photography: better color balance
The color that an object appears will depend on the color of the light hitting it. A banana looks yellow because that is the main wavelength of light that gets reflected from it. But what if the light source doesn't emit much yellow light?
For example, a banana will look red if you photograph it during a glorious sunset, because the light coming from the sun contains a lot more red. If you were to photograph it under a blue fluorescent bulb, it would look bluer for the same reason.
Your brain naturally corrects for this: you know bananas are yellow, so it appears yellow to you, even if that is not the color of most of the light being reflected from it.
Digital cameras are not as smart as your brain, so your pictures will look unnaturally blue if you are photographing under a fluorescent lamp.
You may have seen a setting in photo editors called white balance. This controls for the color of light coming from the light source. Adjusting the white balance allows you to up or down-weight the three sensor colors.
You can adjust the white balance of a JPG file, but you shouldn't if you can avoid it. You can convert RAW sensor data to a JPG, but you cannot do the reverse transformation. The program therefore has to guess the orginal color intensities, and the white balance correction will not be as accurate.
Further advantages of RAW photography: more colors
There's another reason to use RAW files if you plan do edit the photo before sharing it.
JPG files store the color of each pixel as an RGB value. This value is three numbers that correspond to the amount of red, green, and blue needed to make up that pixel's color.
Each of the three colors is stored using 8 bits of memory, which allows it to take any integer value from 0 to 255 (i.e. 0, 1, 2, 3, etc...).
This means that each pixel can be any one of 16,777,216 colors (the maximum possible number of colors is called the color depth). The eye can only see about 10 million colors, so 8 bit color sounds like it should be more than adequate. But...
Many image editing methods, such as increasing the contrast or recovering detail from shadows, stretch out the colors of the original image. What looked like a smooth color gradient in the original image now becomes an ugly stepped texture:
Editing RAW files reduces this problem because they store colors using more bits of memory. RAW editing programs use this to allow you to edit with much greater color depths (only converting to 8 bit color at the end when you save the result as a JPG at the end).
Result: much nicer looking images.
Unfortunately, not every Android phone supports RAW capture. The feature was only released in the latest versions of Android, but it also requires that the phone hardware supports it. If the conversion to JPG is done within the camera unit before sending the image to the Android operating system, then you won't be able to get the RAW sensor data even if you upgrade your phone to the latest version of Android.