Advanced and Legacy Methods
This topic describes two Bayer CFA decoding methods respectively named Legacy and Advanced.
The two methods transforms the raw Bayer CFA data stream issued by the camera into an RGB color data stream using a 3x3 kernel. The missing pixel components are reconstructed from the nearest components.
The Legacy interpolation method computes the missing color components by applying exclusively the Mean() function.
The Advanced interpolation method computes the missing color components using the Mean() and the Median() functions. It eliminates the aliasing effect on the highly contrasted sharp transitions in the image.
Functions Definitions
The min() function returns the lowest integer value from a set of 2 integer values.
The max() function returns the highest integer value from a set of 2 integer values.
The mean() function returns one integer value that represents the mean value of 2 integers. It is computed as follows:
Function | Mean(a,b) |
---|---|
Formula | (a + b + 1) >> 1 |
The median() function returns a set of two integer values that are the two median values of a set of four integers. It is computed as follows:
Function | Median(a,b,c,d) |
---|---|
Value 1 formula | Min [ Max(a,b); Max(c,d) ] |
Value 2 formula | Max [ Min(a,b); Min(c,d) ] |
Decoder operation
For each pixel of the source image, the CFA decoder computes two missing color components from surrounding pixels.
The text hereafter describes how the 4 central pixels located at positions 22, 32, 23 and 33 of a 4 x 4 Bayer CFA array are computed:
The relative positions of the surrounding pixels are identified by compass markings:
Component | Method | Formula |
---|---|---|
R22 | Legacy, Advanced | R22 |
G22 | Legacy | Mean[Mean(N,S), Mean(W,E)] |
Advanced | Mean[Median(N, S, E, W)] | |
B22 | Legacy | Mean[Mean(NW, SW), Mean(NE, SE)] |
Advanced | Mean[Median(NW, SW, NE, SE)] |
Component | Method | Formula |
---|---|---|
R23 | Legacy, Advanced | Mean(N,S) |
G23 | Legacy, Advanced | G23 |
B23 | Legacy, Advanced | Mean(W,E) |
Component | Method | Formula |
---|---|---|
R32 | Legacy, Advanced | Mean(W,E) |
G32 | Legacy, Advanced | G32 |
B32 | Legacy, Advanced | Mean(N,S) |
Component | Method | Formula |
---|---|---|
R33 | Legacy | Mean[Mean(NW, SW), Mean(NE, SE)] |
Advanced | Mean[Median(NW, SW, NE, SE)] | |
G33 | Legacy | Mean[Mean(N,S), Mean(W,E)] |
Advanced | Mean[Median(N, S, E, W)] | |
R33 | Legacy, Advanced | B33 |