Bayer Filter

A Bayer filter is the color filter array (CFA) placed directly over the photosites on a digital camera’s image sensor. Each photosite on the sensor is inherently monochromatic: it can measure the intensity of light but not its color. The Bayer filter solves this by covering each photosite with a tiny red, green, or blue filter, so each pixel records only one color channel. The camera’s processor then reconstructs the full-color image through a mathematical process called demosaicing.

The Bayer Pattern

The Bayer pattern arranges filters in a repeating 2×2 grid: one red, one blue, and two green. The ratio is 50% green, 25% red, and 25% blue. Green gets double representation because the human eye is most sensitive to green light, and the luminance (brightness) information that defines perceived sharpness is weighted heavily toward the green channel. By dedicating half the sensor to green, the Bayer pattern captures more of the detail that the eye cares about most.

Demosaicing

Since each pixel records only one color, the camera must estimate the other two. This interpolation process is called demosaicing. For a green-filtered pixel, the camera calculates the red and blue values by analyzing the neighboring red and blue pixels. The algorithm considers the surrounding pattern of values to produce the most accurate color prediction. Simple algorithms average the nearest neighbors. Advanced algorithms analyze gradients and edges to avoid introducing artifacts at sharp transitions. The quality of the demosaicing algorithm significantly affects the final image’s color accuracy, sharpness, and artifact levels.

Limitations and Artifacts

The interpolation process can introduce artifacts. Moire patterns appear when fine, repetitive details interact with the regular filter grid. False color (color fringing along high-contrast edges) can appear where the demosaicing algorithm misjudges the color at a sharp boundary. Many cameras include an optical low-pass filter (anti-aliasing filter) in front of the sensor to slightly blur the image and reduce these artifacts, though this comes at the cost of some sharpness.

Alternatives to Bayer

While the Bayer pattern dominates the market, alternatives exist. The X-Trans filter (used by some manufacturers) arranges red, green, and blue filters in a more randomized 6×6 pattern that reduces moire without needing an anti-aliasing filter. The Foveon sensor takes a fundamentally different approach: instead of filtering light by position, it stacks three layers of photosites that capture red, green, and blue at every pixel location, recording full color at each point without interpolation. Each approach involves trade-offs in sharpness, color accuracy, noise performance, and processing complexity, but the Bayer filter remains the most widely used because of its mature processing algorithms and balanced performance across all conditions.