First, based on the Android Platform Basic filter algorithm implementation
1,android provides a method to change the image value ColorMatrix, through the ColorMatrix method can achieve basic filters, such as black and white, gray, yellowing and other effects.
2, change the image value by ColorMatrix, generate the transformation matrix, use matrix multiplication, to change the pixel value of each point.
Matrix =
R1 |
R2 |
R3 |
R4 |
R5 |
G1 |
G2 |
G3 |
G4 |
G5 |
B1 |
B2 |
B3 |
B4 |
B5 |
A1 |
A2 |
A3 |
A4 |
A5 |
After the change
R ' = R * R1 + G * R2 + B * R3 + A * r4 + R5;
G ' = R * G1 + G * G2 + B *g3 + A * g4 + g5;
B ' = R * B1 + G * b2 + B *b3 + A * b4 + b5;
A ' = R * A1 + G * a2 + B * a3 + A * A4 + a5;
Section the The column is the control hue, the first 4 column is the control of transparency, the first 5 column is the increment value of the component
3,R,G,B,A Change in the value of the coefficient will modify the effect of the image
(1) The diagonal value is 1.0, the other is 0 , the image is guaranteed to be the original image
Original image |
R |
1.0 |
0 |
0 |
0 |
0 |
G |
0 |
1.0 |
0 |
0 |
0 |
B |
0 |
0 |
1.0 |
0 |
0 |
A |
0 |
0 |
0 |
1.0 |
0 |
(2) If the diagonal value is greater than 1.0, the other is 0 , the image is lit
Image is light-biased |
R |
2.0 |
0 |
0 |
0 |
0 |
G |
0 |
2.0 |
0 |
0 |
0 |
B |
0 |
0 |
2.0 |
0 |
0 |
A |
0 |
0 |
0 |
2.0 |
0 |
(3) If the diagonal value is less than 1.0and the other is 0 , the image is dark
Dim image |
R |
0.5 |
0 |
0 |
0 |
0 |
G |
0 |
0.5 |
0 |
0 |
0 |
B |
0 |
0 |
0.5 |
0 |
0 |
A |
0 |
0 |
0 |
0.5 |
0 |
(4) Set the image to Gray, by checking the data R 0.3 G0.59 B 0.11
Dim image |
R |
0.3f |
0.59f |
0.11f |
0 |
0 |
G |
0.3f |
0.59f |
0.11f |
0 |
0 |
B |
0.3f |
0.59f |
0.11f |
0 |
0 |
A |
0 |
0 |
0 |
1.0 |
0 |
4, according to the above implementation, the realization of the basic filter algorithm is
Public Bitmap Getblackstyle (Bitmap src) {Bitmap dst = Bitmap.createbitmap (Src.getwidth (), Src.getheight (), config.argb_ 8888); Canvas canvas = new canvas (DST); ColorMatrix cm = new ColorMatrix (); Set the image to Gray, by checking the data R 0.3 G0.59 B 0.11cm.set (new float[] {0.3f, 0.59f, 0.11f, 0, 0, 0.3f, 0.59f, 0.11f, 0, 0, 0.3f, 0.59f, 0. 11f, 0, 0, 0, 0, 0, 1, 0}); Paint paint = new paint ();p aint.setcolorfilter (new Colormatrixcolorfilter (cm)); Canvas.drawbitmap (src, 0, 0, paint);// Save Image Canvas.save (Canvas.all_save_flag); Store Canvas.restore (); return DST;}
Third, post-filter era
On the Internet to see some information and camera applications, many camera players on the use of mobile phone cameras are more and more, as a mobile phone camera developers need more creativity and features for mobile phone camera luster! The following points of the camera development direction for your reference:
( 1 ) Live Filters
VIDA is a photographic application from a domestic team that features real-time filters that you can preview to the final finished product while shooting. This is the direction of a enhanced filter function. Unlike the simple addition of new filters, real-time filters hold the essence of what you see.
( 2 ) GIF Animations
gifshop is an application that makes stop-motion animations fast. It combines the narrative ability of the dynamic picture, preserving the small volume characteristics of the picture. But gifshop 's problem is also very prominent, compared to record life, it is more suitable for the creation of some humorous dynamic sketch. Once the " creation " is involved , the user's threshold has been relentlessly improved. But the idea of making the screen move is a little farther than the simple enhancement filter.
( 3 ) Motion Picture
Cinemagram produced images can be animated only in a particular area. You can then create a " moving poster "that is popular online. Compared to gifshop , it can make ordinary notes and photos become a bit magical. Due to the ingenious design of the application, it is suitable to apply to different occasions. The user's threshold is relatively small, but the harvest is quite large. I regard it as an improved version of Gifshop.
( 4 ) Sound + picture
picle is an app that lets you record a piece of audio while you're taking a photo. The advantage is that the interesting role of " pip " is involved in the narrative of the photo. Compared to the above application,picle enters another dimension, which takes into account the narrative bottleneck of the picture and tries to break through by adding audio. the problem with picle is that it creates a new format that is now only shared within the picle system.
After the filter era of the team in different directions set a different bottleneck, and through a certain way to break through. The starting point of thinking is no exception to the enhancement of the image narrative ability. From the present situation, there are some things worth noting:
· Volume: cannot be bloated because of enhanced effects.
· subject matter: The user's usage scenario cannot be restricted because it is particularly suitable for a particular subject.
· format: Start with the existing popular format and avoid using the new format.
· threshold: Seek balance in the user's interests and use of complexity.
· Multimedia: Do addition on the picture, but not into the shooting video.
It is believed that with the enhancement of hardware technology, the mobile phone will become a new type of photographic equipment. It may not replace the traditional camera, but it can become irreplaceable because of the application. As you can foresee, the filter will not be the last stop of the mobile phone camera.
Android Camera Live Filter (iii)