Measuring color, Part 1

Submitted by Nate Dappen on Sun, 2011-01-16 23:36
Nate Dappen's picture

Visual Methods in Science Series

Measuring animal color using digital photography: Part 1

By Nathan Dappen

The evolution of animal coloration is one of my primary interests as an evolutionary biologist. How is color used by various organisms? What evolutionary processes lead to or limit color variation? Why are there often differences in color between males and females or among populations of the same species living in different environments? The study of animal coloration can provide a powerful model for understanding the mechanisms that lead to natural phenotypic variation, and ultimately how this variation influences various evolutionary processes.

To answer questions about color evolution biologists need ways of measuring color. While color may seem straight forward to quantify, those who study it know that it can often be a real headache to measure. This article is part one in a series of short tutorials, which will explain a few ways digital photography can be used to measure animal coloration for research purposes. In this segment, I will briefly explain some of the physics of color in terms of the human visual system, summarize the basics of how cameras create digital images from available light, and explain how to objectively measure the percentage of an animal’s body that is covered by a specific color as well as the actual size of those color patches in the units of your choice using digital photographs.

Why “we” see color: Color, as we experience it, is a qualitative and subjective interpretation of light. Color is the result of our nervous system (i.e. our eyes sending information to our brain) picking up how various wavelengths of light are being absorbed or reflected off of objects around us. Every color that you can imagine seeing is the result of various combinations of light wavelengths between 380nm and 700nm being reflected or absorbed off of objects. Our eyes have three main cone cell types that act as light receptors. These three cone cells peak in absorbance at different wavelengths – low, middle, and high – of the visual spectrum (Figure 1). Low, middle, and high wavelengths correspond roughly to what we think of as blues, greens, and reds respectively – three colors that can be mixed together in specific quantities with black or white to create every imaginable color (See Wikipedia chart below). This “mixing” of different wavelengths of light is essentially what our brain does with the information that it gathers from each receptor in our eye in order to create the various colors that we perceive. (FIGURE 1)

FIGURE 1

TABLE 1

So, here’s a question: what is the color of a red apple in room with no light? If you guessed black, you were wrong. Black is the result of objects absorbing all light. If there is no light in the room, the apple would be colorless—a concept that our brains aren’t really built to understand. The important lesson is that our body’s “measurement” of light wavelengths, is color. This brings up several interesting points. First, not all organisms (or people for that matter) interpret light in the same way. For example, many birds, reptiles and fish can see wavelengths in the ultraviolet spectrum (≈300-400nm) – a spectrum that is wholly invisible to us. While we have three light receptors, many birds have four and some butterflies have six! What this means is that what looks like one color to us, may look very different to another organism. Additionally, many organisms can distinguish between various shades of color much more effectively than we can. 

When measuring animal color for research purposes, we have to consider these differences. Animal color evolves in the context of the survival and reproduction of that species. Therefore, the way we interpret an animal’s coloration may be meaningless in terms of its evolution. The way to deal with these issues is to measure an animal’s coloration as objectively as possible. New tools in digital photography are allowing us to do this more accurately. But before I go into some of the basic measurement techniques, let me briefly explain a little about how digital cameras turn light into digital colors.  
 
How color works with digital photographs

RGB: Most digital cameras on the market use an image-capture method called single-shot, which refers to the number of times the camera’s sensor is exposed to the light passing through the camera lens. When your camera takes a picture, light passes through the lens and hits the sensor, which is made up of many pixels. Most pixels use a Bayer filter mosaic method to capture the light. In the Bayer filter mosaic method each pixel on the sensor has three light-sensitive receptors organized in a checker-board pattern (Figure 2). Each receptor is specifically sensitive to a different range of wavelengths: reds, greens, and blues. When light hits the sensor of most cameras, the raw information collected by your sensors can range anywhere from 8 bits to 16 bits (with most dSLRs in the 12 to 14 bit range). A raw converter will then translate the information in each pixel into three values that range between 1 and 255: one value for red, one for greens and one for blues (hence RGB color space). The specific combination of these red, green and blue values can create almost every color within the human visual system. A one megapixel picture has a million RGB value sets (each pixel has a value between 1-255 for red, green, and blue respectively). That’s a lot of information.

 
 
 
You should also consider that there are a variety of different color spaces, each of which vary in accuracy and ability to render the range of visual colors. For example, most cameras use an sRGB color space, which cannot render all the visual colors and therefore wont be totally accurate. There are other color spaces, such as Adobe RGB that have a wider gamut. The level of accuracy needed to measure animal color depends entirely on the type of analysis that you require. To read more about color spaces click here.
 
When you take pictures in a non-RAW format, light is not recorded equally for the red, green and blue sensors. This is because digital cameras are built to make reality look good to us, and the receptors in our eyes do not absorb red, green and blue light equally. Therefore, the companies that manufacture these cameras tell the cameras to adjust the red, green and blue values of each pixel to mimic the way our eyes interpret light. Most cameras accomplish this by using post-capture algorithms when information is compressed into smaller file formats like JPG. Therefore, when you are measuring animal color, you’ll want to make sure that you are shooting in RAW, a format that captures and records the raw data with less manipulation of the original data than a more compressed file like JPG.
 
White balance: If you take a picture of a piece of paper in the sun and then take the same picture indoors under an artificial light, the paper will look different. The camera sensor will adjust its RGB values based on what it thinks white is. Because different light sources produce different wavelengths of light, objects that may look white in one light environment, may look slightly different in another. If you want to use photos to compare the color of multiple organisms, you need to make sure that each individual is photographed in a similar light environment and that each image has a white standard in the image. Having the white standard in the picture will allow you to compare your images to images taken in a slightly different light environment (although it’s best to take pictures of all the organisms you are comparing under the same light environment). You can learn about white cards and a way to achieve consistent white balances click here.

What kind of camera do I need?  For my research work, I use a canon Rebel T2i. While I recommend that you use a dSLR, any digital camera that can shoot RAW images and allows the manual setting of white balance and exposure will work just fine. Because the sensors on different cameras have slightly different sensitivities, its best if you use the same camera to take pictures of all the organisms that you want to compare. Keep in mind, most dSLR’s use cutoff filters to eliminate light outside the visual spectrum such as ultraviolet or infrared wavelengths. Many organisms may reflect light at these wavelengths. If you don’t plane to use a camera that can pick-up these wavelengths, it is crucial that you use a spectrometer, before you begin measuring color with digital photographs, to make sure that your organisms do not reflect light outside of what can be perceived by your digital camera.

 
Measuring and comparing the size of a color patch:

Step 1 - photographing your organisms: This first step is the most difficult (and most important) step in measuring and comparing animal color. The best way to start is to set up an indoor studio with entirely artificial lighting. Outdoor light environments change constantly and it’s better if you can control as many variables as possible. I use several studio lights and a single flash (although two is better). Even if you are controlling the light environment, I think it’s best to put a white standard in all the images you take. In the off chance that you take several pictures in another light environment, the color standard will allow you standardize the while balance in all of your images. I use a mini Macbeth Color-standard, which is small and relatively inexpensive. I also use a tabletop background; you can make this at home using a sheet or tablecloth.

Set-up your camera on a tripod in a fixed location with one of your flashes hooked to the shoe-mount (if you have two flashes and one of them can act as a slave master, use that in the mount and set up the second flash to eliminate any shadows cast by the shoe mounted flash). Set your lens at a fixed focal length. Use manual exposure for both ambient and flash. Your white balance (and therefore colors) can shift dramatically if the ratio between ambient and flash exposure changes. Differences in the color and size of your subjects will cause this ratio to change unless you have both flash and ambient exposures set manually. I recommend using a remote control to release the shutter. This way, you can hold each organism in a similar position and place while photographing them. It is important that each organism is photographed at the same angle and that the distance from the camera and lights remain the same so that they are equally comparable.

Make sure that the color standard is in clear view within the photo frame and is being exposed by flash lighting in a way that is similar to the organism. Set the white balance on your camera according to the white square on the color standard. Shoot away. If all of your subjects are shot under the same light, with the same exposure in RAW file format, you should be able to objectively and directly compare colors in all of your images.

Step 2 - calculating the proportion of an animal that has a specific color: Transfer the image you took of your organism to your computer and open the image in Photoshop. Below is one image that I took of a lizard that I study (Figure 3).

 
 
FIGURE 3
 
I’m interested in looking at color on the lateral side of this lizard. The first thing that I need to do is decide how I want to standardize the area that I am measuring. For my case, I will measure the proportion of a specific color, relative to a total area. I need to make that total area a similar location on each lizard that I photograph. So, I’m going to crop out all the area that I’m not interested in using the Crop tool. I’ll make a similar crop when measuring color for every lizard image. For my study, I decided to analyze the rectangular area defined by the dark dorsal color on the top, the lizard’s belly on the bottom, the back of the lizard’s front legs on the left, and the front of its back legs in the right (FIGURE 4).
 
 
FIGURE 4a,b,c
 
Looking at this new rectangular image of scales we can see that there are several clearly distinct colors. The first color that I see is black scales (Figure 4 a), then I see light blue/green scales (Figure 4 b), and finally, there are a few darker blue spots on the scales where the ventral scales begin (Figure 4c.) Let’s measure how much of this lizard’s side is made up of these three scale colors.

First, let’s calculate the total area of the lizard’s side. You can see that there is a small portion in the bottom of the image that is not part of the lizard, so we need to select the entire image except for that small portion. To do that, select the Selection tool and press Control A to select the entire image. Next select the quick selection tool. Set the tool to negative (-) in the option bar at the top of the window and carefully deselect the portion of the image that is not part of the lizard (Figure 5).

 
 
FIGURE 5
 
To measure the total area selected, go to Analysis > Record Measurements. The measurements log should show up at the bottom of the page with all the details of the selection including the area of total pixels selected. In this image, the total number of pixels that make up the black scales was 158699 pixels (Figure 6).
 
 
FIGURE 6
 
Ok, so now we know the total number of pixels. What proportion of that area is represented by the pixels that make up the black scales? Choose the magic wand tool and adjust the tolerance at the top to a value appropriate to whatever image you are working with. In this example, I set the tolerance to 15. Click the area you want to select with the magic wand. In my image, I selected on of the black patches. Now, hold the control button and click somewhere within that selection – a menu should pop up. Select > Similar (Figure 7).
 
FIGURE 7
 
All the areas with similar color should immediately become selected. Often, the selection is not perfect and you’ll need to go through the selection with the magic wand or quick selection tool and make sure that all the areas that interest you are selected. When the all the lizards black scales seem to be selected to your satisfaction, go to Analysis > Record Measurements. The area of the selected area should show up in the Measurement log at the bottom. For this image, the area of black scales is made of 53145 pixels (Figure 8). 
 
 
FIGURE 8
 
Go through the same process with the blue/green and blue areas and you should know the pixel area of all the different color types.  

Now, to know what proportion of the lizard’s side is made-up of black scales you can simply divide the black pixel area by the total number of lizard pixels (53,145/158,699= 0.3349). So, on this lizard, 33.49% of its side is made up of black scales. We can then do the same thing with all the other colors.

Calculating color-patch sizes: Maybe you are not interested in the relative size of a color patch, but instead want to know actual real-life area in a unit other than pixels. Open the original image in Photoshop. The first thing that you will need to do is to set a Measurement Scale. Lucky for us, we put the same color standard in each of these images and can use it to standardize how many pixels in each image actually represent a real-life unit like centimeters or inches. 

Take a ruler and measure the distance in mm from one corner to another corner on a single color square on the color standard. In my color standard, a single square is exactly 10mm from corner to corner. To tell Photoshop how many pixels should equal a certain length select Analysis > Set Measurement Scale. The Measurement Scale box will pop up. Make sure that the Preset is set to custom, the Logical Length is set to 10, and the Units are set to mm. The ruler tool will automatically be active. Zoom in on the color standard and trace, from corner to corner, the side of the square on the color standard that you previously measured to be 10mm with the ruler. Once you have done this, click OK in the Measurements Scale Box. Your images will now be set to scale (Figure 9).

 
FIGURE 9
 
Next, follow the directions I outlined above to select and measure the areas of specific color patches. When you click the Record Measurements for your selection, the Measurements Log will present the area of the color patch as mm2. 
 
Important note: These are two good ways of measuring colors that can be perceived to the human visual system. Many color patches reflect light that cannot be perceived by humans, such as ultraviolet (UV) light. It is crucial that you use a spectrometer, before you begin measuring color with digital photographs, to make sure that your organisms do not reflect light outside of what can be perceived by your digital camera (in particular UV reflectance). 
 
Next time, I’ll describe how to make more complex spectral measurements using the program ColourWorkerTM, which can make spectral estimates based on digital photographs. 
 
Please feel free to download this article here and share it with whomever you see fit.
 
------------------
Nathan Dappen is currently pursing his PhD in Evolutionary Biology and Animal Behavior at University of Miami's Department of Biology. In addition to his work as a biologist Nathan works in a diverse range of photographic fields (www.nathandappen.com) and has published his work in various national and international books, magazines and websites. Along with Neil Losin, he is a cofounder of Day’s Edge Productions a web based production company dedicated to producing films about science and nature (www.daysedgeproductions.com).