A mosaic of red, green and blue filters laid over the pixels of a color sensor, one filter per pixel, with two green pixels for each red and blue one.
Also called: Bayer filter, color filter array, CFA
A pixel only measures an amount of light, not its color. The Bayer matrix puts a red, green or blue filter in front of each pixel, in a 2 × 2 pattern repeated across the whole sensor (for example RGGB): half the pixels are green, a quarter red and a quarter blue, mimicking the eye's greater sensitivity to green. It is named after Bryce Bayer, who patented it in 1976.
To produce a color image, software rebuilds the two missing colors at each pixel from its neighbors: this is demosaicing, or debayering. In astrophotography it is done after calibration, on the raw data. The software needs to know the exact order of the pattern (RGGB, GRBG and so on), otherwise the colors come out wrong.
Each color is sampled by only some of the pixels. Behind a hydrogen-alpha filter, which passes only red light, just one pixel in four receives signal, which is why narrowband imaging is more efficient with a monochrome camera. Dual-band filters exist for color sensors, recording hydrogen-alpha on the red pixels and oxygen III mostly on the green and blue ones.