Android Camera Real-Time Filter (1), androidcamera
1. The Android system has built-in filter functions.
Filters have more than 20 different effects, not inferior to those produced by the popular smartphone app Instagram.
2. color matrix ColorMatrix
In android, you can use the color matrix (ColorMatrix class) to operate the color. The color matrix is a matrix of 5x4. It can be used to modify the values of each RGBA component in the image. The color matrix is stored as a one-dimensional array as follows:
[A, B, c, d, e, f, g, h, I, j, k, l, m, n, o, p, q, r, s, t]
He uses the four RGBA channels to directly operate the corresponding color. If Photoshop is used, he will know that sometimes the processing image is made special by controlling the different color channels of RGBA.
The effect of this matrix on color is calculated as follows:
The calculation rule of the matrix is to multiply one row of matrix A by one column of matrix C as A row of matrix R,
The C matrix is the ARGB information contained in the image. The R matrix is a new color component after applying the color matrix to C. The calculation result is as follows:
R' = a * R + B * G + c * B + d * A + e;
G' = f * R + G * g + h * B + I * A + j;
B '= k * R + l * G + m * B + n * A + o;
A' = p * R + q * G + r * B + s * A + t;
Ps: 1st ~ Three columns control the color phase, 4th columns control transparency, and 5th columns control the added value of components.
3. Basic filter effects:
If we use ColorMatrix to adjust the proportions of RGB colors, we can achieve effects such as monochrome, black and white.
4. Implementation of the Lomo filter effect:
Change Image value + mask