Talk about picture filters, phone, lookup table (color lookup Tables

Source: Internet
Author: User
Tags image processing library

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.