Today we're going to look at the lookup table (the Color Finder), in short, by converting each of the original colors into a new color.
For example, the original color is red (r:255,g:0,b:0), converted to green (r:0,g:255,b:0), and all the red places will be automatically converted to green.
The Color lookup table is the one-time (matrix) conversion of all the colors, and many of the filter functions are to provide a matrix of such a transformation, based on the original color color conversion.
Introduction: Thank Grey Ash in looking for Hu Turnip Carrot
Link: https://www.jianshu.com/p/b470a5b5a560 Original Lookup Table
However, the iOS comes with an image processing API that does not provide color lookup table-related content. Even so, the understanding of the gpuimage to provide us with a relevant interface, today to briefly introduce the usage.
1 Image Add filter effect
Resources: one picture (optional), Photoshop
A) load the original image into Photoshop
Original Sample Picture
b) Adjust the adjustment panel in Photoshop to adjust the image and achieve satisfactory results.
Adjust the image in the adjustment panel
The adjusted image
c) Perform the same adjustment for original lookup table (original color lookup tables) Once satisfactory results are achieved
Before adjustment
After adjustment
D) Save the adjusted lookup table as Newlookuptable.png
2 referencing lookup table in code
Gpuimage is a fairly well-known third-party image processing library, and this library is not covered here.
Gpuimage has a filter function Gpuimagelookupfilter specifically for lookup table processing, which allows you to add a filter directly to a picture using this function.
Originalimg is the original picture you want to add the filter to
-(UIImage *) ApplyFIlter: (UIImage *) originalimg {
UIImage *inputimage =originalimg;
UIImage *outputimage = nil;
Gpuimagepicture *stillimagesource = [[Gpuimagepicture alloc] initwithimage:inputimage];
Adding filters
Gpuimagelookupfilter *lookupfilter = [[Gpuimagelookupfilter alloc] init];
Import a newlookuptable.png file that was previously saved
Gpuimagepicture *lookupimg = [[Gpuimagepicturealloc] initwithimage:[uiimageimagenamed: @ "NewLookupTable.png"];
[Lookupimg Addtarget:lookupfilterattexturelocation:1];
[Stillimagesource addtarget:lookupfilterattexturelocation:0];
[Lookupfilter Usenextframeforimagecapture];
if ([lookupimg processimagewithcompletionhandler:nil] && [Stillimagesource Processimagewithcompletionhandler:nil]) {
outputimage= [Lookupfilterimagefromcurrentframebuffer];
}
return outputimage;
}
So the filter can be added successfully, very simple, haha.
That's right, gpuimage. This library will have a lookup table in the picture, in the Gpuimagelookupfilter related folders, you can find.
Chat slice filter, on phone, lookup table (color lookup Tables