So the previous section described how almost all consumer cameras add color to what is essentially a collection of B&W pixels. But this is just the first step of the many steps your camera takes to turn an image into a .jpg. Want to see the other steps? Have a look at Figure 15-7.
Figure 15-7: All of the things your camera does when generating an in-camera .jpg. |
As you can see, once the data is read off the sensor, the demosaicing process commences, and then the camera will start to do what a one-hour photo lab would do (using settings from the Creative Styles (Section 6.26) as a guide). It then compresses the image and writes it to the memory card as a .jpg format.
Let me provide a little more detail on the above. The process of creating .jpgs is synonymous with the process of throwing away information. 12- or 14-bits of data per channel from the sensor gets squeezed into 8 bits of data per channel (giving up some tonality and fine shades of color). A little bit of dynamic range gets lost too. Then lots of visual information that the human eye and brain cannot perceive gets thrown away, which is what’s responsible for JPG’s famously small size. If there is a lot of high-frequency detail in the image, then that gets replaced by what’s called a .jpg compression artifact (which I describe in a couple of sections). Then the compressed .jpg image file is written to the memory card, and then the raw information from which the .jpg was produced is discarded (unless you were wise enough to shoot in RAW + JPG mode). Once this information is gone, you can’t get it back. If you didn’t like what the camera did when throwing away the extra dynamic range, you can’t go back and fix it.
Figure 15-8: The green boxes represent what happens when shooting RAW: the camera saves only the raw, unprocessed data so it can be processed (and re-processed, if desired) on your own terms, on your own time. The steps in the grey boxes are skipped. |
So what happens when you shoot RAW then? When you shoot RAW, the camera just sucks the data off the sensor and writes it directly to the memory card (executing just the green squares in Figure 15-8), leaving you to do all that other image processing later on your computer. (Well, that’s what happened in the old days. With modern Sony cameras, some of the way the light intensities are represented are manipulated a bit before being written to the memory card. (See TIP at the end of Section 15.7). But as far as you’re concerned, it’s still an unprocessed image with no color, sharpening, contrast, or saturation applied.
The whole idea of just capturing the raw, unprocessed data (which is where the term RAW file came from) stems from the fact that there might be other commercial software out there that can process the image differently / better than the camera’s firmware can, or not compress the image at all like the camera normally would when creating a .jpg. We’ve already seen differences in what 3rd party software can do with the demosaicing process, and similar differences exist with different noise reduction packages too. Shooting RAW is just like shooting negatives and laboriously printing every picture in your home darkroom.
The raw data file also has some notes in it – it knows, for example, what your white balance was set to, and what the contrast, saturation, sharpness, and noise reduction settings were. Those settings aren’t actually applied to the RAW data, mind you -- those notes are there for the benefit of the desktop-computer-based raw conversion software, so when the file is opened and demosaiced, it can apply these settings in a reversible way to your image and you can start tweaking it from there. This way, there’s no danger of accidentally setting the wrong color balance, or having too much in-camera sharpening which can’t be undone – none of that is actually applied until it gets to your computer, and even then, at that time it’s still all optional.
So should you shoot RAW or JPG? Don’t answer that question until you read the section about .jpg compression artifacts (Section 15.6). That might change your mind in a hurry.
Have you ever used a program like WinZip or StuffIt? These two programs are designed to email many computer files to another person. First it collects the many files into one big file, and then it “compresses” that one big file so it takes up less space on your hard drive, and also makes it faster to email. The kind of compression used in this kind of application is called “lossless”, since when it is received at the other end and decompressed, the resulting collection of files must be absolutely, bit-for-bit identical to the original files before compression.
RAW: RAW is simply pulling the bits off the sensor and shoving it into the memory card.
TIFF: TIFF is not offered by your camera, but you’ll need to know about this when working with other imaging professionals. This was one of the earliest standard file formats for storing images, and offers the highest image quality format (because there is no compression whatsoever). Although TIFF image files produce images of the highest quality, their files sizes can be quite large – usually much larger than the equivalent RAW files!.
JPG: This is the most popular image format in the world. At the time that the image file formats were being established, the Joint Photographic Experts Group (JPEG for short) got together to establish an alternative file format that would be substantially more compact than TIFF files. Comprised of experts in imaging, perception, cognitive science, computer science, and mathematics, the JPEG group devised a method of “compressing” an image by throwing away information that the human eye and brain cannot perceive, thus reducing the file size tremendously without significantly altering how the image appears.
Figure 15-9: An oversimplified computer representation of a Japanese Flag |
As a simple example of how files get “compressed”, let’s start with an image of a Japanese Flag, which is a large red dot in a plain white rectangle. When stored as a RAW file, the information is arranged something like what’s in Figure 15-9 (pretend the red parts constitute a circle). With a 24 Megapixel camera, this information plus the header info (plus some thumbnails which usually get embedded into an image file) usually adds up to quite a large size: (4000 pixels) x (6000 pixels) x (8 bits per pixel) = 195 Megabits = more than 24 Megabytes!
When stored as a compressed file, however, the Japanese Flag image might be represented something like this: “Okay, the first row has 417 pixels that are all white. The second row has 312 pixels that are white, followed by 87 that are red, followed by 312 that are white”, and so on for each row. (In reality, the compression is much more complex than that, involving trig functions and wavelets and other compression algorithms. But the general idea is that very clever methods are used to throw out information the eye cannot perceive at a distance, and then represent what’s left in clever ways that take up less space.) Because a more detailed image would require more words than “This much white / this much red” to describe it, images containing a lot of detail will be slightly larger than images that are simple (like the flag example above). This is why no product brochure or manual can ever tell you with certainty how many images will fit onto a memory card – when shooting in .jpg, it all depends on the content of the image. The most significant advantage of shooting with .jpg is the sheer number of images you can fit onto a card – up to five times more than if you were to shoot with RAW.
The downside is that .jpg’s are compressed using a “lossy” compression algorithm – unlike with the WinZip or StuffIt examples described earlier, when the image is uncompressed the resulting file is NOT the same as before it was compressed. For a Microsoft Word or Excel document this would be quite unacceptable; but for images that will only be looked at visually (and not computed upon), this is considered not only acceptable, but preferable (“Look how much memory card space we’re saving!!!”)