Bayer filtering

Most single-chip image sensors used in digital still and video cameras and scanners, are overlaid with a Bayer filter mosaic to create a color image.

This is a color filter array (CFA) arrangement of RGB color filters on a square grid of photosensors.
The filter pattern is 50% green, 25% red and 25% blue. a.k.a. RGBG, GRGB or RGGB.

Bryce Bayer of Kodak patented this in 1976.
He distinguished between:

Cone photoreceptor cells are less sensitive to light than the rod cells in the retina.
However they allow the perception of color. These cone cells are most sensitive to green light.
So, human eye physiology dictates the design of twice as many green elements as red or blue elements.
The human retina uses M and L cone photoreceptor cells combined, during daylight vision, for luminance perception.

Humans usually have three kinds of cones with different photopsins. They have different color response curves.
Thus, we have trichromatic vision.

These color sensor elements, aka sensels, sense light intensities. These after interpolation with neighbouring sensels, become image pixels.

De-mosaicing

The raw output of Bayer-filter camera sensors is called a Bayer pattern image.

Each pixel records only one of three colors (Red,Green,Blue) filtered by the Bayer filter mosaic.

A de-mosaicing algorithm is an image processing algoritm used to reconstruct a full color image from the Bayer pattern image.
It interpolates a set of complete red, green, and blue values for each point.
The de-mosaicing algorithm is part of the processing pipeline required to render these images into a viewable full-color image.

Different algorithms result in final images of varying-quality.
Of course each algorithm uses a different amount of computing power.

De-mosaicing Bayer patterns can be done in-camera, using the camera's built-in firmware to produce a JPEG or TIFF image.

Many modern digital cameras can save the raw data directly from the sensor, in a raw format.
The user may then, demosaic it themselves, outside the camera, using external software in a PC.