Currently, there are two main types of photosensitive elements: one is the photosensitive element of the widely used mosaic form (Bayer), and the other is the patented product of foveon, the photosensitive elements of X3 technology have different principles.
Bayer mode:
X3 mode:
Bayer is the original image inside the camera. Generally, it is suffixed with. Raw. Many software can be viewed, such as PS.
We camera down to store .jpeg on the storage card or other format pictures, are converted from. raw format
There are multiple storage methods in the .. raw format, but in any case, the first two rows are arranged differently.
The format may be as follows:
G r
B g
G r
B g
The horizontal direction is a multiple of 2 and the vertical direction is a multiple of 4. They constitute a resolution. For example, the above represents a resolution of 8*4.
Bayer diagram.
We need to know that G = 2 * r and G = 2 * B, that is, the green value is twice the red value or the blue value, because
Human eyes are more sensitive to green, so the green weight is heavier.
The following describes the algorithm for converting a Bayer image to an RGB image. An RGB image is a three-color image. A pixel is converted from RGB.
Three colors constitute a mixed color, while a Bayer image has only one pixel, or R, G, or B. Because Bayer
A pixel has only one color, and needs to be interpolated (filled) by the color around the pixel.
The two colors do not need to be inserted. The general algorithm is:
For inserting R and B,
RX = (R1 + R2)/2; or ------------- obtain the average value of the top and bottom, or the average value of the left and right sides.
RX = (R1 + r2 + R3 + R4)/4; ---- average of the Four Edges
B. Similarly, for example:
G B g
R g r
G B g
For g in the middle, it lacks R and B, and is evaluated by the average values of up and down and left and right.
For
B g B
G r g
B g B
In this figure, the center point R, lack of G and B, G is not discussed at the moment, then B is to calculate the average value from the four B angles of R.
========================================================== ======
It is a little complicated to insert G.
However, a general algorithm is the same as R and B. The complexity of a complex algorithm is doubled, but the accuracy is higher.
For video monitoring systems, the accuracy is not too high. simply use the R or B solution. The following describes the complexity:
For graphs:
R1
G1
R4 G4 R G2 r2
G3
R3
For the intermediate point R, it needs to insert G and B, B is not discussed, mainly discusses g, it has four points around 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 surrounding pixel color is B, it should be compared | B1-B3 | and | B2-B4 | value.
========================================================== ================
Also, I do not want to discuss the algorithm for converting RGB format to YUV format.
Note that the value of each pixel of a Bayer is 8 bits, but some cameras have 10 bits and 12 bits in the Bayer format.
For 14-bit and 16-bit data, how can we convert the above 8-bit data into 8-bit data ?. Take 12-bit data for example, some
If a person takes 8 or 8 digits in height, a problem may occur. This image may have a slope, either bright or partial.
Dark, or other messy problems, the color problem is always unsatisfactory. At this time, we need to correct it, no doubt
A waste of time.
Another algorithm is to use Log ing. According to foreigners, this conversion method has a high accuracy. For 12 bits, the general conversion algorithm is as follows:
F (in) = 2 ^ (log (in) * 8/12)
Conversion chart:
| 8.
|.
|.
| _______________________ 12
Because log256 = 8 and log4096 = 12, the log base is 2.
A better algorithm may be used to adjust the algorithm based on other factors such as the exposure provided. In this case, some exceptions may occur.
When an event occurs, the generated image will not be distorted seriously.
Refer:
Http://www.cnblogs.com/lin1270/archive/2010/12/01/1893647.html
Http://forum.xitek.com/forum-viewthread-tid-337763-extra--action-printable-page-1.html