Bayer colour interpolation
The interpolation of the missing colour values from the surrounding pixel values can be done in many ways which require different computation times but have significant effects on the resulting colour image. 2x2, 3x3 kernels or complex multi-level software calculations can be applied in order to suppress artefacts. The interpolation is particularly difficult at right angles to the edges of colour ranges. Depending on the algorithm (nearest neighbour, linear, cubic, ...), comb-like fringed or smooth edges are formed.
Example of a 3x3 interpolation:
In case of a block of 3x3 pixels, the central pixel is surrounded by 8 neighbours. Four pixels are arranged directly vertically and horizontally, four others diagonally. The missing colour information of the other two colour channels of the central pixel is calculated from these pixels by averaging the neighbours.
The calculation of the green component for a blue or red pixel is often still more sophisticated in case of a 3x3 kernel. A colour field is often not homogeneous, but object edges or colour boundaries run through the image. Due to the large amount of green neighbours, these image zones would provide bad results. Because of this, the other neighbours of the four green pixels are examined: in the case of the blue pixel, these are four pixels again, two of them arranged horizontally, two vertically. Depending on their brightness, the green value can be calculated only from (G1+G3)/2 or (G2+G4)/2. In case of a horizontal change of the blue colour values, the horizontal pair of green (G1+G3)/2 is taken and vice versa. The green interpolation for a red pixel is done accordingly.