How the Bayer Filter Works, and Why Your Camera Sensor Is Colorblind

14 hours ago 7

Every photosite on your camera's sensor is colorblind. A 61-megapixel full frame sensor is a grid of roughly 61 million tiny light meters, and each one reports a single number: how much light it collected during the exposure. It records the brightness and nothing about the color. Left alone, your sensor would only ever hand you a grayscale image.

Your Sensor Counts Light, Not Color

A photosite is a well of silicon that turns incoming photons into electrons through the photoelectric effect. The more light that lands on it, the more charge it accumulates, and the camera reads that charge out as a value, usually across 12 or 14 bits, which gives it anywhere from about 4,000 to 16,000 possible steps between pure black and clipped white. That is a very precise brightness meter. It also cannot report wavelength. A red photon and a blue photon each land as charge with no label attached, so the raw signal coming off the silicon carries no way to tell them apart.

This is the part that surprises people who assume the sensor sees red, green, and blue the way a screen displays them. It does not. Silicon responds to a broad band of wavelengths, stretching well past what your eye can see and into the near infrared, and it lumps all of it into one running total. Whether the chip is CMOS, as in essentially every current camera, or the older CCD, the principle is identical: one photosite, one number, one shade of gray. To build a color photograph out of that, the camera has to introduce color before the light ever reaches the silicon.

A cross-section of the color filter array: incoming light passes through a red, green, or blue filter before reaching the photosites below, so each one records only a single color. Diagram by Cburnett, CC BY-SA 3.0. Source

The Color Filter Array That Gives Color Back

The fix is a color filter array, a sheet of microscopic colored windows bonded directly over the sensor so that one tiny filter sits above each photosite. A photosite under a red filter mostly receives red light, so its brightness count now means "how much red landed here." Do the same with green and blue filters across the grid and the sensor starts recording color, one channel at a time, one photosite at a time.

The pattern that almost every camera uses came from Bryce Bayer, a scientist at Eastman Kodak, who filed the patent in March 1975. It was granted on July 20, 1976, as U.S. Patent 3,971,065, titled "Color Imaging Array." Bayer's arrangement is a repeating two-by-two block of four filters: one red, one blue, and two green, laid out so the two greens sit on one diagonal and red and blue on the other. Tile that block across millions of photosites and you get a mosaic that is 50 percent green, 25 percent red, and 25 percent blue. Half a century later, that layout still sits on top of the sensor in nearly every dedicated camera you can buy, and in a grouped-pixel form, marketed as Quad Bayer or Tetracell, on most modern phones.

The Bayer color filter array: a repeating 2x2 block of one red, one blue, and two green filters that makes the finished grid 50 percent green. Diagram by Cburnett, CC BY-SA 3.0. Source

Why the Grid Is Half Green

The lopsided count is deliberate, and it maps onto how you see. Human vision leans heavily on green. The eye is most sensitive to wavelengths in the green part of the spectrum, and the brightness signal your brain uses to judge sharpness and fine detail, what engineers call luminance, is dominated by green. Green light contributes far more to perceived brightness than red or blue does. Bayer understood this and built it into the patent, where he described the green photosites as the luminance-sensitive elements and the red and blue ones as chrominance-sensitive.

Doubling up on green means the sensor samples the luminance detail your eye cares about most at twice the density of the color information it cares about less. It is a smart way to spend a fixed budget of photosites. It also has a practical side effect that shows up in your files: the green channel is usually the cleanest of the three, carrying the least noise and the most real detail. That is one reason a black-and-white conversion that leans on the green channel often looks better than a flat average of all three.

Demosaicing: Rebuilding Two-Thirds of Every Pixel

Here is the catch. After the exposure, every photosite has recorded exactly one color. The red sites know nothing about green or blue, the green sites know nothing about red or blue, and so on. Your raw file is that literal mosaic, a patchwork of single-color brightness values that is missing two-thirds of the color data at every location. It is not yet a normal image, which is a large part of why a raw file needs processing before it looks like a photograph.

The step that fills in the gaps is called demosaicing, sometimes debayering. For every photosite, the converter estimates the two colors it did not record by reading its neighbors: a red site borrows green and blue values from the surrounding green and blue sites, and the process repeats across the whole grid until every location has a full red, green, and blue triple. That estimate is educated guesswork, and different algorithms guess differently. Simple bilinear interpolation is fast and just averages the nearest neighbors. More sophisticated methods, like Adaptive Homogeneity-Directed interpolation or the AMaZE algorithm in RawTherapee, follow edges and textures so they do not smear them. This is why the same raw file can look meaningfully sharper or cleaner depending on whether you open it in Lightroom, Capture One, or DxO. Lightroom and Adobe Camera Raw share Adobe's processing engine and render a file the same way, but point Capture One and DxO at a picket fence or a tweed jacket and one may draw clean lines where another leaves colored fringing along the edges, because each is running a different reconstruction of the same incomplete data. If you want to pull more out of that reconstruction, a focused raw processing course pays off quickly.

From raw mosaic to finished photo, in five stages from the top: the original scene; the raw sensor response, where every photosite holds a single brightness value; that same response color-coded by the RGGB filter over each photosite; the image rebuilt by demosaicing, still soft and carrying color artifacts; and a full-color reference version of the original for comparison. Diagram by Cmglee, CC BY-SA 3.0. Source

The megapixel number on the box hides all of this. A 61-megapixel Bayer sensor really does have 61 million photosites, but it never measured 61 million full-color pixels. It measured 61 million single-color values and interpolated the rest. The color resolution is real, and modern demosaicing is very good, but the color at each pixel is reconstructed, not directly captured.

Moire, False Color, and a Filter That Blurs on Purpose

Sampling color on a sparse grid and then guessing the rest has a failure mode. When a scene carries a fine repeating pattern, a tight fabric weave, a distant brick wall, a bird's feathers, the pattern can beat against the sensor's own grid at a spacing the demosaicing cannot resolve. The result is moire, those rainbow ripples and false colors that appear where no such color exists in the scene. It is aliasing, the same artifact that makes wagon wheels seem to spin backward on film.

For years the standard defense was an optical low-pass filter, also called an anti-aliasing filter, a thin layer over the sensor that blurs the incoming image by a hair, on the order of a single pixel, to smear out detail too fine to sample cleanly. It trades a little sharpness for protection against moire. As sensor resolution climbed, some manufacturers decided the trade was no longer worth it. Nikon sold two versions of the same body, the D800 with the filter and the D800E with its effect cancelled, and many high-resolution cameras since have dropped it entirely, betting that photosites packed tightly enough make moire rare and the extra bite of detail worth the risk. When it does show up, raw converters include color moire reduction to knock it back, though it cannot always be fixed cleanly.

Fujifilm took a different swing at the same problem. Its X-Trans sensors keep red, green, and blue filters but drop them into a larger, more irregular six-by-six pattern, about 55 percent green, that puts all three colors on every row and column and scatters the repeats. The added randomness is meant to break up the interference that produces moire, which lets Fujifilm leave the anti-aliasing filter off without the same artifact risk. The price is that the unusual layout needs its own demosaicing math, and for years some raw converters rendered X-Trans files softer or mushier than the sensor deserved.

Color aliasing on a Bayer sensor: a fine black-and-white checkerboard beats against the filter grid and produces false colors that were never in the scene, shown as captured (left) and after demosaicing (right). Diagram by Bautsch, CC0. Source

The Sensors That Refuse to Guess

A few designs sidestep the mosaic entirely. Sigma's classic Foveon X3 sensor stacks three photodiodes at every location, one above the other in the silicon, and exploits the fact that red, green, and blue light penetrate silicon to different depths, roughly 0.2, 0.8, and 3.2 microns. Blue is absorbed near the surface, green a little deeper, red deeper still, so a single stacked site measures all three colors directly. No color filter array, no demosaicing, no anti-aliasing filter. The images have a distinctive per-pixel bite, but the design has stayed niche, held back by weaker high-ISO performance and slower readout, and Sigma has spent years working toward a full frame version.

The Foveon X3 stacks blue, green, and red photodiodes at increasing depth in the silicon, so a single location measures all three colors directly, with no color filter array and no demosaicing. Diagram by SaxSub, CC BY-SA 4.0. Source

The other route keeps a normal Bayer sensor but moves it. Pixel shift, offered on cameras like the Sony a7R VI, takes several frames while moving the sensor between them in precisely controlled steps. Over four shots, every point in the scene gets covered by a red, a green, and a blue photosite in turn, and Sony's desktop software combines them into a file with a true red, green, and blue measurement at each location, skipping interpolation altogether. A sixteen-frame mode adds half-photosite steps on top of that, sampling between the photosites to quadruple the pixel count to roughly 240 megapixels, again assembled on the computer rather than in the camera. The catch is obvious the moment you try it: the subject and the camera both have to hold still, which is why pixel shift lives on a tripod in front of static scenes. For everything else, a colorblind sensor, a Bayer mosaic, and a good demosaicing pass remain the machinery inside almost every photograph you will ever take.

Lead image: the Bayer color filter array, a mosaic of red, green, and blue filters bonded over the sensor with two green filters for every red and blue, diagram by Cburnett, CC BY-SA 3.0. Source.

Read Entire Article