Category Archives: Color and Vision

Smarter image resizing

A bunch of us around the office were talking about the cool content aware image resizing algorithm that we saw on Doug’s blog.

The idea behind Shai Avidan and Ariel Shamir‘s work is to find information-neutral “seams” in the image and fold or expand the image along those constantly shifting fault lines. Unlike traditional methods for resizing images, “important” areas don’t become smaller at the same rate as low information areas. As a result, things can move around a bit in the resized images. Take a look at the video above to see this in action, or read the paper for information about how it works.

A seam is a connected path of low energy pixels in an image. On the left is the original image with one horizontal and one vertical seam. In the middle the energy function used in this example is shown (the magnitude of the gradient), along with the vertical and horizontal path maps used to calculate the seams. By automatically carving out seams to reduce image size, and inserting seams to extend it, we achieve content-aware resizing. The example on the top right shows our result of extending in one dimension and reducing in the other, compared to standard scaling on the bottom right.

Personally, I think this is another step in our cultural evolution with respect to imagery. First we believed every photograph represented an actual event that was faithfully transcribed. Photography was an optical-mechanical process of transcription, according to its earliest practitioners (and detractors). Then mid-20th century we realized imagery could be manipulated in order to entertain, mislead, or manipulate us; but we still more or less believed that images were inherently truthful. After another half-century we’re still coming around to the fact that images are surfaces that we project our thoughts and feeling onto and, as a result, must be treated rather skeptically.

Image manipulation techniques such as this — which change image content in a way that moves around visual elements automatically while attempting to retain the information within a scene — may finally highlight some latent connections between our mind’s images and those that are recorded. We’re constantly evaluating the content of scenes and unconsciously throwing out most of the “uninteresting” information, transforming the world’s “truthiness” along the way. Recorded images have no more inherent truth than people’s faulty memories do.

Posted in Color and Vision, Fodder for Techno-weenies, Life Lessons, Photography | Leave a comment

Deconstructing an image

Friends, I’ve been wanting to tell you about this for a while, and now that the beta public version of MATLAB R2007b is out, I can finally post. This will be the first of a series of articles about high dynamic range imaging. Let’s start by looking at a picture:

This is my office. It’s a window office. I don’t say that out of pride, rather to highlight that there’s a bright, sunny world out there beyond the window. It’s comparatively dark inside. In fact, it’s so much brighter outside in this scene, that contemporary digital cameras and films can’t record the full “dynamic range” of the image. The outside would be overexposed or the interior would be underexposed. High dynamic range (HDR) imagery solves the problem.

I will write more about dynamic range later, but I want to get around to deconstructing the image’s content. For now I hope the following pair of images show how amazing high dynamic range imagery really is.

The description of these images gets a little technical, and you can safely skip this paragraph . . . or you can pick up some new highfalutin party lingo. The image on the left shows the relative luminance (i.e., brightness) of the scene. The darkest value is black; the brightest value is white; and everything in between is linearly scaled. As you can see, the wide range of luminance values hides most of the scene’s information. If we take the base-2 logarithm of the values, linearly map the result, and apply a false coloring (as shown in the right image) you can see that all of the detail is actually there in the HDR image. (Click on any of the images for a larger version.)

For this image, knowing the way that it’s constructed may help you understand some of the visual content of the image. Right now — in what will soon be the olden days — the easiest way to get the “best” exposure is to use a handheld lightmeter and then change the lighting throughout the scene to produce even illumination. You can see one of these soon-to-be-antiquated devices on the right-hand side of my desk right next to a wee cowboy and dinosaur facing off and a copy of what I was reading at the time. A tiny version of this device (minus dinosaur and cowboy) appears inside almost every camera.

Using a light meter and portable lighting can be very time consuming and a bit expensive. You need equipment. You need assistants to set up and move the equipment. You need time to set it all up, make the test images, adjust the light output, take the “best” shot, and tear it all down again. I predict that HDR technology will appear in consumer electronics devices in the next few years — it’s already in Adobe Photoshop — and, while professionals will still need lighting rigs and serfs assistants, the rest of us will get most of the benefits without extra equipment. Mark my words, the move from traditional imagery to HDR imaging is going to be (almost) as big as the shift from film to digital.

MATLAB and the Image Processing Toolbox are used by the engineers who will likely develop those fancy consumer devices for you. So I created this image as a sample that ships with the toolbox to help show what we can do. One day I brought in my sturdy tripod, and Alex Taylor (who went to a trade show in California with me last February) brought in his new Nikon digital camera. We took seventeen “normal” low dynamic range images at different exposure values, ran it through some software I wrote in MATLAB to merge the different exposure values into one “properly exposed” image, called a function in the Image Processing Toolbox to create a “tone mapped” image, and voilà.

The last time I did something like this was six years ago when I needed to make a new colorful image for the toolbox. Being a perfectionist (and a bit of an artiste) it took me forever to think of what I wanted to do. Then one morning I remembered Edward Weston’s sexy peppers, grabbed my tripod and an old bed sheet, and bought thirteen dollars worth of peppers at the Stop & Shop. A couple days later I went to San Diego for my first trade show, and my coworkers ate the peppers. (Déjà vu…) My inspiration appears on the left below, along with the image that still ships with the toolbox and appears in multiple product demos.

  

The first image I made for the toolbox appears in the new image. (That’s MATLAB in the background.) I also put an apple in the picture as an homage to the earlier picture and a reference to my absent Mac laptop.


Finally, there are a bunch of dinosaurs in the picture because everyone loves dinosaurs. Or at least, they should.

Posted in Color and Vision, Computing, Photography | 2 Comments

Retinas are different but see the same thing

Here’s your color and vision article for the week from Dr. Color’s assistant (via the good people over at LiveScience.com).

The first images ever made of retinas in living people reveal surprising variation from one person to the next. Yet somehow our perceptions don’t vary as might be expected.

Imaging thousands of cells responsible for detecting color in the deepest layer of the eye, scientists found that our eyes are wired differently. Yet we all — with the exception of the color blind — identify colors similarly.

The results suggest that the brain plays an even more significant role than thought in deciding what we see.

Posted in Color and Vision | Leave a comment

Ask Dr. Color’s Assistant: Saturation

Dear Dr. Color:

For the last few decades photographers have been infatuated with saturation. I suspect that if prints were compared with the original views that they would be more saturated than reality. It certainly does ‘punch up’ the picture though.

What is saturation, though? How about the term “vibrance” that Adobe is throwing around?

Believe it or not, there are actually ISO standard technical definitions of most color terms. Here’s a definition from the CIE’s “International Lighting Vocabulary” (1987). Saturation is “colorfulness of an area judged in proportion to its brightness. Note: For given viewing conditions and at luminance levels within the range of photopic vision, a color stimulus of a given chromaticity exhibits approximately constant saturation for all luminance levels, except when the brightness is very high.” Colorfulness is a perceptual attribute of how chromatic something is.

So you can decouple chroma (more or less the same as hue) from luminance and saturation. The farther you get away from neutral for a given hue, the greater the saturation. Essentially, if something seems very colorful (now matter how bright it appears) it’s more saturated. So you pretty much have that right. But it’s not exactly the same as color purity in a spectral sense, because many colors (like the purples) can be quite saturated but are always a combination of other colors.

It’s true that in RGB space, when you want to saturate colors you have to move R, G, and B away from neutral, which can have undesirable consequences for other colors. Different color systems are much better at these color transformations, in particular HSV (or HSL) and L*a*b*. I’m a big fan of L*a*b* for saturation manipulation because it’s completely decoupled from luminance/brightness, and it’s easy to perform via scalar multiplication for all colors at once; there’s no need for curves and no impact on overall color-balance as long as a* and b* are multiplied by the same amount.

As far as I can tell, “vibrance” is a completely nontechnical term. In Adobe products it “is a more selective version of the Saturation slider. Whereas the Saturation slider increases the saturation of all of the tones in your image, the Vibrance slider limits its saturation boost to primary colors, leaving skin tones and other secondary shades untouched.” Sounds like an adjustment in L*a*b* space that is greatest along the a* and b* axes.

Posted in Color and Vision, Photography | Leave a comment

Ask Dr. Color’s Assistant: Determining Monitor Luminance

Dear Dr. Color:

I wish to measure the brightness of my LCD monitor so that I can set it to the recommended brightness for photo editing work. How can I convert the measurements from a hand held exposure meter to candles per square meter or NITS?

First, you must be using a spot meter; incident lightmeters won’t work for this task. (I suppose you could use an incident meter in a room with no other illumination…) Then compute the exposure value using your light meter, which shouldn’t be too hard: just collect f-stop, shutter time, and ISO setting. That’s easy. The tricky part is to determine the meter’s calibration constant. According to Wikipedia, it’s probably 12.5 (for Canon, Nikon, and Sekonic) or 14 (for Minolta and Pentax). Take all of those numbers and put them into this equation:

((calibration constant) * (f-number)^2) / ((time) * (ISO speed))

The resulting value is luminance in candelas per square meter. There’s your radiometry lesson of the day.

But I wonder, doesn’t your monitor calibration tool perform this as one of the first steps? Mine, the consumer-level Monaco EZ-Color suite, does. And if you’re that worried about brightness, you’ll probably need to worry about other aspects of the ISO standard: surround illumination, specular highlights, etc. Those other factors determine apparent brightness and color values, which is probably what you’re worried about. And isn’t Photoshop’s soft-proofing good enough?

Posted in Color and Vision | Leave a comment

How does light get to the back of the retina?

The eye is a funny thing. One interesting factoid is that the light sensitive rod and cone cells are actually buried within the retina, sandwiched between cells that give structure and perform the first parts of image formation. “If that’s the case,” you might ask, “how does light reach the photoreceptive cells?”

Research published in the May 15th issue of the Proceedings of the National Academy of Sciences, shows that Müller cells actually transport light through the retina. Basically they’re little optical fibers that guide light directly to rods and cones, increasing the eye’s efficiency and explaining the unusual location of the light-sensitive cells. (I learned about the paper via a summarizing article in July’s issue of Biophotonics International.)

Here’s an executive summary from PNAS:

An image focused by the lens on the front surface of the retina is conveyed by Müller cells to rods and cones on the retina’s rear face. Kristian Franze et al. observed that, when light is applied to the dissected retina of a guinea pig, a lattice of bright spots 2 µm in diameter and spaced 6 µm apart appears on the far side. The authors stained the retina with dyes and antibodies specific to Müller cells and confirmed that these long, funnel-shaped cells, which bridge the full thickness of the retina, are responsible for the light transmission. Held in a laser trap, Müller cells transmitted light efficiently across an optical gap. The cells’ refractive index is higher than that of surrounding tissue, and although their shape is not as regular as that of artificial optical fibers, they effectively function as such.

Posted in Color and Vision | Leave a comment

Digital Imaging Workflow

“Is it true that if you don’t use it, you can lose it?” — Steve Carell, “The 40 Year Old Virgin”

Sometimes . . . at least temporarily. Or so I discovered when my inkjet prints looked terrible. Colors were muddy or just plain wrong: yellow got into my blues, green got into my reds, green was the wrong green, etc. I had forgotten my not-so-secret sauce for printing from Adobe Photoshop.

Fortunately, I had written it all down a few years ago and could go back to the digital workflow that has worked so well for me. (Addendum: Make backups.)

Crisis averted. Confidence restored.

Posted in Color and Vision, Computing, Fodder for Techno-weenies, Photography | 3 Comments

Photography Technology Education from Google

I’m not one of those amateur photographers who conflates technology and picture-making. Gamma, MTF curves, ISO numbers, CCD, CMOS, ICC profiles, colorspaces, optics — you can make great images without really knowing what they technically mean or how they work. But my day job relates directly to imaging and image processing, so I end up learning a lot about them anyway.

Someone at the office pointed out a series of photography technology lectures at Google. Titles include:

Geek out!

Posted in Color and Vision, Photography | Leave a comment

Ask Dr. Color’s Assistant – Colorspaces

Dr. Color’s assistant here. Here’s a recent question from the good doctor’s answering service that will be of interest to photographers.

Hi, Dr. Color? What colorspace should I use with my new digital camera? What is a colorspace anyway?

A colorspace is the set of all possible colors that can be represented by a set of values, usually (R,G,B) triples, but also L*a*b* and CMYK and XYZ and so on. This collection of colors is known as the gamut.

(You might be questioning the possibility of the same RGB value — say (255,128,128) — looking different on two different devices. Trust me, friends, it’s true. If you don’t believe me, fiddle with the buttons on the front of your monitor and watch the colors change.

Three things influence the gamut of a colorspace:

  • The color of the red, green, and blue primaries
  • The color of “white”
  • The bit-depth of the image

We’ll look at each of these in turn.

RGB has three primaries: red, green, and blue. Changing the color of any of those primaries — either by fiddling with the buttons on your monitor or by changing the values in your color calculations — changes the color of every other (R,G,B) triple in your colorspace, creating a new colorspace. The easiest way to visualize this is via a chromaticity diagram, which shows all of the visible colors (for a given luminosity).


The sRGB colorspace (from Wikipedia)

The three corners on the triangle on the chromaticity diagram are the colors of the red, green, and blue primaries. Notice that the primaries don’t actually extend to the corners of the chromaticity diagram for this colorspace. Colors outside the triangle can’t be represented by (R,G,B) numbers. The primaries determine the size of the gamut.

The chromaticity diagram above only shows one slice through the gamut, corresponding to a particular level of luminosity (roughly equivalent to lightness). The actual gamut is all of the slices for the various luminosity values. The brightest white and its color provide another axis through the colorspace. (It’s actually true that there are different colors of white: daylight white, flourescent white, tungsten white, and so on.)

To get technical for a moment, the primaries determine the span of the linear combination of the primary colors; while the whitepoint determines the weights for the linear combinations. Together they determine where a particular (R,G,B) triple will fall on the chromaticity diagram, which is in device-independent xyY (or xyL) space.

Finally, the bit-depth of the image determines the spacing between the colors. Because the individual red, green, and blue components must take discrete values (e.g., 1, 2, 37, and so on) there are gaps between neighboring colors. Bit-depth is the range between the minimum and maximum values for each color channel. An 8-bit image has R, G, and B values that vary between 0 and 255. For 16-bit images, these values range from 0 to 65,535.

Obviously, if you edit an image in a higher bit-depth mode, you can either (1) pack more colors together or (2) expand the colorspace to include more colors. Actually you can do both. Conversely, if you choose a very wide colorspace but a low bit-depth, your image will have banding where neighboring pixels show unpleasant jumps in color. For example, it’s generally unwise to edit an 8-bit image in the very wide ProPhoto RGB colorspace.

So what colorspace should you pick?

First off, don’t pick sRGB for editing. As you can see in the diagram above, the colorspace is rather small. It’s really only good for preparing images for the web.

If you’re storing your RAW images for later processing, consider ProPhoto RGB. It’s very wide, but you should only edit in 16-bit mode.

A nice compromise is Adobe RGB (1998). It’s much wider than sRGB but not as big as ProPhoto RGB; yet it’s still possible to edit in 8-bit mode without too many problems.

Of course, you will use different colorspaces when printing and displaying images, but you shouldn’t use these for editing or storing images: The gamut of your monitor or printer is almost always smaller than a good editing space. Often sRGB is smaller than these gamuts, highlighting why it’s such a bad idea to use it for editing.

Posted in Color and Vision, Fodder for Techno-weenies, Photography | Leave a comment

Five Questions from a friend

My long-time friend and the most academically accomplished person that I know — who wishes to remain nominally pseudonymous but whose quirky pseudonym I just can’t bring myself to use — sent me the following interview questions.

1. What’s it like to be a photographer sans depth perception? Do you think such vision helps or hinders, and why?
To be honest, I really don’t know what it’s like to lack depth perception. I learned around age six or seven that I don’t have it after my ophthalmologist put a pair of funny glasses on me and showed me a picture of a very, very large fly. Apparently, if I’d had stereoscopic vision, I would have seen its wings pointing out at me instead of being flat on the page. Occasionally I wish that I had it — mostly when pulling into parking spots — but I don’t really miss what I can only vaguely imagine.

Last autumn, I did try wearing a contact to replace my missing lens, but it didn’t work out. I was a bit disappointed but a bit relieved, too. I worried that my photography would become more difficult or change in uncontrollably bad ways if my manner of looking at the world fundamentally changed.

I gather from talking to my differently sighted friends that the way my eyes work may be amenable to photographic seeing. The world around me is undeniably flat. I get my sense of perspective by moving around and by remembering (without thinking) how large things should be. Having the world pre-flattened takes away a large part of what I hear makes photography difficult for some people.

Of course there’s a lot more to photography than compressing what’s visible by one dimension. I still find it hard sometimes to manage clutter in the frame and ensure that what I’m seing in my mind’s eye actually makes it onto film. Harder still is picking what to photograph so that each new image fits with rest of a project and says the right thing (and hopefully something meaningful, too).

2. What do you miss most about Iowa and Wyoming?
For a while, Wyoming had the tourism slogan “Like no place on Earth.” Maybe they still do. At any rate, it’s not exactly true; Wyoming is America’s Iceland, minus Björk.

It’s large, but everyone knows each other. One day while bored in a meeting, I calculated that I had probably met around 10% of the people my age in Wyoming. I knew a lot of really great people from all over the state, and we saw each other quite frequently. With just a few dozen high schools — there were fewer than ten cities with more than 10,000 people when I lived there — we were always going to common athletic and academic events.

I suspect a lot of that 10% has moved away; certainly most of my friends have — the people you might put in the “chattering class.” We chose liberal arts trajectories that didn’t involve the University of Wyoming, and during the bust years of the 1990s, we were probably the state’s biggest export. My mother is still there, and I miss her a lot. But I also miss the serendipity of constantly running into people I knew wherever I went.

Plus, Wyoming is just fantastically beautiful. Because everyone who visits the state only goes to “The Parks,” we have most of the the state’s 100,000 square miles to ourselves, and we’ve kept the best parts secret.

My feelings for Iowa are a lot harder to put into words. I was born there and molded into the person I’ve spent years unbecoming. But I also spent four wonderful years in Grinnell, where I met most of my favorite people in the world and learned a lot, including many things I didn’t realize until after I had left. The half-dozen times that I’ve been back since then — visiting the rest of my family, who I also miss a lot — are all about change, too.

So it may seem odd to say that the thing I think I miss the most is Iowa’s impossible changelessness. It’s so different whenever I go back. (Every place in the world shares this trait!) But in essentials, it’s still the same open-air cave where I spent fifteen years of my youth and four more years not long afterward. I like that I can see traces of my family and myself whenever I drive down any self-similar county road or main street. I love the way that the smell of dirt there reminds me of the edge of town where we always seemed to live. That same smell reminds me of a particular wintry day in ninth grade when my friend and I walked along a frozen creek that had cut deep over the years into the Iowa loam, upon which the brilliant sun shone, sending steam into the air and making me see the world anew.

3. When did you become such a fashionista, and why? Did Lisa have anything to do with it?
It all started shortly after moving to the Bay State. One Sunday at the laundromat I picked up an abandoned copy of the New York Times. Shortly afterward I was hooked and we subscribed. If you haven’t experienced the Sunday Times in print, then you probably can’t appreciate the pure avarice that its advertisements embody. At three dollars a week I was unconsciously soaking up bits of fashion knowledge.

A few years later, Lisa graduated from Law School. Though she decided not to practice, she still needed a new work-appropriate wardrobe. I went along and progressed from simply possessing inchoate fashion knowledge to actively participating.

Around 2002 I started working with a very fashionable, very wonderful person around my age whose tastes ran toward the expensive side. We discussed designer lines the way that we might talk about television shows: “Did you see Galliano’s new line?” and so on. At almost the same time I happened upon a copy of W in the Newton Free Library’s magazine swap bin. The magazine’s high-end fashion photography — occasionally showing fashion disasters — drew me in. Of course, I was hooked.

I had also started a self-guided tour through the library’s extensive photography book collection. It has an endowment especially for photographic monographs, and I proceeded more or less alphabetically. A lot of the early books contained fashion photograhs: Avedon, Beaton, Bourdin, etc. Meanwhile I was perusing old issues of Aperture, a high-end art photography magazine, and came across an article which argued quite convincingly that (some) fashion photography is actually art first and advertising second, which suited me fine since I was starting to see couture as art that uses the body as substrate. (I’m more worried about the bluring lines between celebrity and commerce than art and commerce anyway.)

So I’m no fashion expert, but I can’t hide my love for it either.

4. How do you think your job will differ in 5 years? In 10 years?
There’s an enormous tension in software engineering. Newbies start out not knowing as much as we think we do and needing a lot of direction from peers and management. Usually we learn how to do our job well after years of putting in our dues. But by the time we become masters of the craft, we are also deeply involved with a lot of other project and people management activities that reduce the amount of time that we can actually spend applying our software construction skills. It’s a badge of honour, to be sure, but everyone I know has had a “Why can’t I find time to work on development projects?” moment where they realize how much their job has changed.

In some ways, my job has already started to change in this way, and I suspect it will continue over the next five to ten years. I’m working on my annual performance review right now, and I’m surprised how little time I spent last year working on features for MATLAB and the Image Processing Toolbox. But I’m also amazed by how quickly and correctly I was able to do the things that I did do. (In software engineering, when you take the long view, correctness usually equates to quickness.)

Sometime in the next couple of years, I will have my masters degree and more skills to go along with it. I’m in the optimizing phase of my career right now, where I’m learning how to do things well, instead of how to do them for the first time. In the next five or ten years I suspect that I’ll move into the mastery phase, where I start shaping the world around me rather than being shaped by it.

5. What is the new black?
Black, of course. And never has it looked so good.

I see a red dress, but I want to paint it black.

Your turn!
If you’re interested in being interviewed by me, leave a comment or send an e-mail to jeffmather [at] verizon [dot] net.

Posted in Color and Vision, General, Photography, Software Engineering, This is who we are | Leave a comment

Ask Dr. Color’s Assistant

It’s a crazy time here at The Metrowest Homeopathic Imaging and File Rehabilitation Center — the little office that Doctors Color, Compression, and FFT share with me, Doctor Format. Doctor Compression is happy to have most of the litigation behind him but still feels a bit crunched; FFT (“Fast” to his friends) is moving his practice west, which is just as well because I never understood a single thing he said anyway; and Dr. Color is hitting the greens near Boca this winter.

Dr. Color asked me to answer his mail while he’s away. (To be honest, I’m a little worried that he’s not coming back in the spring, since he’s been talking a lot about Rochester, NY.) I’m not an expert, but I’ve been learning about color vision and perception a bit lately and have been eager to try my hand at answering some questions on colorful subjects. But so far, no mail has come for the good doctor.

So, dear readers, if you have pressing questions about any of the following subjects, please leave a comment or send me an e-mail at jeffmather [at] verizon [dot] net:

  • the physical or psychological basis of color
  • optical illusions
  • color spaces
  • color models
  • photometry, radiometry, or colorimetry
  • color conversions
  • how the eye works

You can even ask more esoteric questions about color such as “Is it true that gray is the new black?” (not anymore) or “Can I use the color wheel to pick matching articles from my wardrobe?” (yes, but at your own peril) or “What is it with red anyway?” (I don’t know, comrade; why don’t you tell me?). Mail addressed to the CIE Standard Observer — Doctor Color’s youthful indescretions finally come to light — will also cross my desk.

Finally, if your eye hurts or you can’t see as well as you could the other day or you see spots when you sneeze, then for god’s sake go see a real doctor!

Posted in Color and Vision | Leave a comment

Reverse-Engineering the Human Visual System

On Monday — just before staffing The MathWorks’ booth — I attended Maria Petrou’s plenary session: “Reverse-Engineering the Human Visual System.” I found it rather interesting, though it tried to cover too much ground for one hour.* Nevertheless, it was quite interesting to ponder how we can use our understanding of the human visual system to perform better digital image processing.

Among the more interesting ideas:

  • There’s a difference between vision and perception. One concerns stimuli, the other processing. One is well-modeled; the other was the reason for the session.
  • The rods and cones of the eye are not located along a grid. It is possible to use normalized convolution to produce acceptable images from a random sample of as few as 5% of the pixels on a regular grid, approximating the visual field. It’s possible to do even better by mimicking the distribution of cones, which are most dense around the fovea.
  • The human visual system performs a form of edge detection in the visual cortex. The principles of these saliency maps can be applied to digital image processing. (For example: Plinio and Li Zhaoping.)

Also of interest: Hiroshi Momiji’s Retinal Vision for Engineers.

* — Perhaps I’ve been out of academia too long. Perhaps medical imaging does less for me than in the past. Perhaps it was just an off-year at SPIE Medical. At any rate, I didn’t attend many paper sessions, but those I did hear were a little disappointing.

Posted in Color and Vision | Leave a comment

Color by Numbers

At the recent medical imaging symposium I bought myself a copy of Daniel Malacara’s Color Vision and Colorimetry: Theory and Applications from the SPIE Press. I managed to read the short monograph on the five hours of flights from sunny, warm San Diego to freezing New England.

It’s not exactly an elementary book, but it covers the mathematical basis of colorimetry. Unlike my article on color vision, Malacara draws upon a lot of research and presents the essential equations of color science — at least those that relate to color measurement.

This is one of the rare books on color vision that leaves the human visual system to the end. In fact, the cone response functions are among the last topics discussed. Instead, this short work of about 150 pages takes a more or less chronological approach to colorimetry, starting with a few fundamentals on colorful light, progressing through basic trichromatic systems (like RGB, XYZ, and xyY) and uniform color systems (such as Munsell, CIELUV, and CIELAB) before ending at color mixing and measurement.

It’s quite a good book for those needing concise definitions and equations. Many diagrams and full-color images complement tables for color matching functions and color transformation equations. In a few places the text is overly terse, and my only wish is that Malacara would have provided a bit more context around some of the equations explaining where some “magical” values come from.

But, all things considered, it’s a work that belongs on the bookshelf of anyone who works with color as numbers.


Posted in Book Notes, Color and Vision | Leave a comment

Color management mailing list

Color management is hard business. I think of myself as fairly savvy in this area, but it took me a long time to get the basics down. (I recommend Tim Grey’s Color Confidence and Fraser, et al‘s Real World Color Management, 2nd ed., for those who want a quick introduction and a thorough grounding.)

People who implement a color-managed workflow — including photographers who print their own images — may be interested in the ICC_Users mailing list.

Posted in Color and Vision, Computing | Leave a comment

How a digital camera works

I began this technical article a week ago to synthesize different things I know about the digital camera pipeline and digital image formation. Photographers may be interested in learning what happens after they trip the shutter and before they import it into Photoshop. If you’re not at all technical, you still may enjoy several of the linked articles, some of which show off optical illusions.

How does a digital camera make an image? It seems like such a simple question with a really obvious answer: Light strikes a sensor which converts it to a grid of numbers that is written to a file.

Well, yeah. But how does that grid of numbers (the image) get formed? Recently I helped someone at work answer that question. The result was this chart:




Click for larger

Not every camera does everything the same way. It’s something of a dark art, really. Camera manufacturers do all sorts of secret, proprietary stuff to tweak images. It’s a fact that vendors don’t like to talk about at parties, but, contrary to popular belief, even RAW files don’t contain the raw sensor data. . . . But I’m getting ahead of myself. Let’s look at the various stages in image formation.

Capturing light with a bucket

To be honest, this is the part that I know the least about. There are hardware guys and software guys. I’ve never used a soldering iron and have probably broken Ohm’s Law on a number of occasions. But here’s the important thing to know. In a digital camera, light (energy) strikes a photosensitive material, which induces a current in a circuit attached to the sensor. More brightness, more energy. More energy, more current. Depending on the type of circuitry used, a separate analog-to-digital converter (ADC) turns the current into a count — CCDs need a separate ADC; CMOS sensors don’t.

The current gets counted at each of the millions of “buckets” on the sensor. In order to create a color image from colorful light, you need to break it down into its red, green, and blue components. The eye does this in a very sophisticated way. A camera is much simpler, separating light into three (sometimes four) components via millions of tiny filters, allowing the components to be individually counted.

“It goes up to 11…”

At this point, light has been converted into millions of counts, which range from 0 (no light) to some theoretical maximum. The count depends on the detector’s sensitivity, the ADC, the amount of light, and the color of light. The maximum possible count determines how many individual brightness levels can be recorded. Sensitivity is typically expressed as “bit depth.” An 8-bit sensor can record 256 (2^8) different levels of light. The more bits, the more distinguishable counts.

Bit depth Number of Levels Minimum Value Maximum Value
8 2^8 0 255
10 2^10 0 1023
12 2^12 0 4095
14 2^14 0 16383
16 2^16 0 65535

Not all pixels are created equal. Some buckets on the image sensor are defective and are always on (“hot”) or always off (“dead”). The sensor itself produces heat (“dark noise”), which it detects when recording the scene. And light “leaks” from a sensor before it gets digitized — imagine a bucket brigade that loses a little bit of water with each hand-off. Better sensors have fewer problems.

The result is noise. Sometimes its speckled (so-called “salt and pepper noise”). Often it isn’t uniform across the sensor. In every case, it should be corrected. Hot and dead pixels are averaged with their neighbors (to the dismay of astrophotographers if done on the image data). Another technique known as “dark subtraction” attempts to remove noise by subtracting the heat noise from the exposure. If the dead/hot pixels are known, they can be masked out. Often this happens before the “raw” image is recorded, making it impossible to get the actual sensor data.

Noise disportionately affects the dark parts of the image. Why? Camera sensors experience light differently than we do. If you double the intensity of light (as measured in absolute units, like lux) the light appears twice as bright to a human observer. As a result, when the intensity of light increases, there are larger gaps in sensor counts between equivalent perceptual changes. At the darker end of a scanner’s sensitivity perceived brightness may double every 32 or 64 values; while at the brighter end a similar perceptual change might require 1024 or 2048 levels. (Charles Poynton describes “gamma” in exhaustive detail.) Consequently, small numerical changes make big noise differences in the darker part of the image.

“This ain’t no image, no RGBG

After digitization and noise removal we still don’t have a recognizable image. There’s no color to it yet and the brightness won’t look right either. Remember that millions of red, green, blue, and (sometimes) cyan filters cover the image sensor in order to provide color accuity. Each filter is only sensitive to one color — blue, for example — but if manufacturers use the right pattern for filters, an algorithm can calculate the the other colors (green and red) at the blue filter’s location. The sensor’s pseudo-image is known as a “Bayer pattern.” A “raw” file contains this pseudo-image along with the metadata needed to construct a final image.

Here is a typical color filter array (Bayer) pattern. Don’t blame me if looking at this image makes you have a seizure. If the image appears to be moving or breathing, well, that’s just a result of simultaneous contrast. It’s natural.

A number of different algorithms “demosaic” this pattern data into the RGB image we’re expecting. Typically, speed and accuracy compete to determine the “best” demosaicing pattern. Some algorithms handle images that contain a lot of pronounced edges better than others. In any case, these algorithm look at neighboring pixels to infer the other colors. Collecting these constructed RGB values into separate red, green, and blue color planes (or channels) expands the information content of an image by a factor of three. Adding information to an image post facto almost always involves subjective judgments about image quality.

After demosaicing, the image is more or less what you would expect a color image to look like but probably nowhere near the final state. Remember that the image contains intensity counts at each pixel location, which is not exactly how we experience image brightness or color. The image requires gamma correction and probaly appears dark. In addition, the color balance is probably incorrect, requiring a white point adjustment.

Gamma correction applies a nonlinear power function to the pixel values, making the pixel values match perceived brightness. Often a separate “tone response curve” is applied to each color channel. The power function — which takes larger numbers and creates smaller output values — has the effect of compressing the image’s effective bit-depth (and its dynamic range), as visually redundant information is squeezed out. Some camera vendors, such as Nikon in its D70 model, perform this gamma compression at an earlier stage in order to reduce RAW file size.

It’s not uncommon somewhere in this stage to remap an image’s values from its effective bit-depth to 8-bits or 16-bits. Image processing and image manipulation applications usually need this in order to display the image correctly. Unlike gamma correction, this is typically a linear remapping.

Making pretty images

Tone mapping adjusts the perceived brightness of image pixels but has very little effect on the color balance of those pixels. Several factors determine the color of image pixels:

  • The individual red, green, and blue (R,G,B) pixel values
  • The color of the “pure” red, green, and blue primaries
  • The whitepoint — that is, the color of white

The primaries determine the color of the most saturated red, green, and blue colors that can be recorded or displayed. In an RGB system, every color is a combination of various intensities of these three primaries. If you change one primary’s definition, every other color is changed accordingly. If you’re having trouble with the concept of multiple “pure” red colors being called “red”, just consider what happens when you fiddle with the color controls on your monitor or television set. You aren’t changing the input values that are displayed, but different colors show up on the screen. Different devices have different red, green, and blue sensitivities; and it’s necessary to take the (R,G,B) values from the camera and put them into a well-understood color space where those particular (R,G,B) values have specific color meanings. Some of these color spaces include Adobe RGB (1998), ProPhoto RGB, and sRGB. Industry-wide adoption of ICC color profiles has largely standardized these color translations.

So how does the white point fit in? When you take your camera into a scene with a different color of light, the camera’s color sensitivity doesn’t change. But the human visual system’s sensitivity sure does! Our brains adapt to the scene’s white point, but the camera does not. As a result, the images that we saw and the camera recorded aren’t the same. A simple white point change corrects this problem. (Some cameras have the ability to record the color of the ambient lighting and store it in the RAW file for later use, which is pretty cool if you ask me.)

Digital cameras can store other information in a RAW file — we’ll get to those special files in a second — that help create “good looking” final images. Some cameras store mask information to hide low-quality portions of the image. Any system that samples data into discrete values introduces errors, which often appear as “steppy edges.” Specifying how much chroma blur to add reduces this unwanted effect. (Any image that is blurred — also a result of quanization — probably deserves some sharpening, too.)

Most mid-level and high-end cameras store the Bayer pattern “image” and the hints for reconstructing it in one of the many RAW file formats vendors have defined. Vendors stuff lots of other information there as well, possibly including a lower resolution lossy JPEG thumbnail and EXIF, XMP, and IPTC metadata. Many manufacturers perform lossless compression on the pixels to reduce the size of the RAW file, but this takes time to do. The possibilities and permutations are endless. DNG is a relatively new format whose proponents hope to unify these proprietary formats.

Now go outside and play

I hope you’ve enjoyed this (sort of) brief description of digital image formation and that you now have a better sense of the factors that impact “raw” images. The imaging world is finishing up its amazing transition from film to digital capture, but the image processing tools and digital pipeline are still evolving. Nowadays, knowing what goes into your raw images is akin to knowing how the Zone System impacts film-based photography. If you know of anything that’s out-of-date, please leave a comment.

Posted in Color and Vision, Computing, Fodder for Techno-weenies, Photography | 6 Comments