Http://www.cnblogs.com/lin1270/archive/2010/12/01/1893647.html
Bayer is the original image inside the camera, and the generic suffix is. Raw. Many software can be viewed, such as PS.
Our cameras take pictures of. jpeg or other format images stored on a memory card are converted from. Raw format. .
The raw format is stored internally in a variety of ways, but in any case, the first two rows are arranged differently. The format might look like this:
G R g R g R g R
b G B G B G B g
G R g R g R g R
b G B G B G B g
A multiple of 2, which is a multiple of 4, which makes up the resolution. For example, the above represents a 8 * 4 resolution of the Bayer Graph.
What we want to know is that G = 2 * R and G = 2 * B, that is, the green value is twice times the red value or the blue value, because
For the human eye is more sensitive to green, so the weight of the green is heavier.
The following is the conversion from Bayer to RGB graph algorithm, RGB graph, that is, a three-color map, a pixel from the RGB
A blend of three colors, while Bayer a pixel has only one color, or R or G or B. Because Bayer
A pixel has only one color that needs to be interpolated (filled) with the color around this pixel. Additional
Two colors, the color of its own will not be inserted. The general algorithm is:
For inserting R and B,
Rx = (R1 + R2)/2; Or-------------the average of the top and bottom, or the average on the left and right
Rx = (R1 + R2 + R3 + R4)/4;----Take the average of four sides
b the same. Such as:
G B G
R G R
G B G
For the middle G, it lacks r and B, which is evaluated by the upper and lower values and the left and right averages.
For
b G B
G R G
b G B
This diagram, the middle point R, the lack of G and B, G is not discussed for the moment, then B, is the four B angle from R to average.
==============================================
If you insert G, it's a little bit more complicated.
However, the general algorithm is the same as R and B, the complexity of the algorithm is also increased by one times, but the accuracy is higher, if the
In the video monitoring system, the accuracy is not necessarily too high, the solution of R or B can be used. Here's the complicated:
For graphs:
R1
G1
R4 G4 R G2 R2
G3
R3
For the intermediate point R, it needs to be inserted G and B, B is not discussed, the main discussion is G, it is surrounded by four points G1, G2, G3, G4.
(G1 + G3)/2--------------If | r1-r3| < | r2-r4|
G (R) = (G2 + G4)/2-------------If | r1-r3| > | r2-r4|
(G1 + G2 + G3 + G4)/4--If | r1-r3| = | r2-r4|
If the pixels that appear around the color are B, you should compare | B1-b3| and | The value of the b2-b4|.
====================================================
There is also an algorithm for converting the RGB format to YUV format, which is not discussed here.
It is important to note that the value of Bayer per pixel is 8 bits. But some cameras have 10-bit, 12-bit Bayer format.
and 14-bit, 16-bit, how do you convert these above 8-bit data to 8-bit data? Take 12 bits of data, some
People are high 8 or low 8, then there will be a problem, this image will have a slope, not light is biased
Dark, or other messy problems, color problems are always unsatisfactory. This time is going to be more positive it is undoubtedly
Waste of time.
The other algorithm uses log mapping, which, according to the foreigner, has a high precision. Take 12 bits, the general conversion algorithm:
f (in) = 2 ^ (log (in) * 8/12)
The conversion diagram is:
|8.
| .
| .
|_______________________12
Because log256 = 8, log4096 = 12, the log is based on the 2 bottom Oh.
Algorithms that do a little better may adjust the algorithm based on other factors, such as the exposure provided, so that when some unexpected
When an event occurs, the resulting picture will not be distorted seriously.
Bayer image Processing