GPUImageLookupFilter is not giving desired result for the following LUT image

679 views Asked by At

I am having this LUT png and when applying this LUT on my image then is not giving the right result. Is my LUT is having a different format or I am not applying filter properly. enter image description here

UIImage *lutimage = [UIImage imageNamed:@"lut.png"];
    GPUImagePicture *lookupImageSource = [[GPUImagePicture alloc] initWithImage:lutimage];
    GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:imported_image];
    GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
    lookupFilter.intensity = 1.0;
    [lookupFilter setInputRotation:kGPUImageRotateRight atIndex:1];
    [stillImageSource addTarget:lookupFilter];
    [lookupImageSource addTarget:lookupFilter];
    [lookupFilter useNextFrameForImageCapture];
    [stillImageSource processImage];
    [lookupImageSource processImage];
    imgview_main.image = [lookupFilter imageFromCurrentFramebuffer];
    [[GPUImageContext sharedFramebufferCache] purgeAllUnassignedFramebuffers];

RESULT IS : enter image description here

BUT RESULT SHOULD BE LIKE THIS: enter image description here

1

There are 1 answers

0
SarahC On

A HALD Look Up Table is a way of translating one input color to one output color. The position in the HALD image is related to the pixels color NOT it's position on the image.

What you've done is add a vignette to a color look up table, so in the bottom right corner of your LUT for instance, you've made that darker. What happens when you apply this LUT to an image is the bright pixels in the image become darker - just as you've told it to. The position in the LUT DOES NOT relate to the images pixels positions, only the RGB intensities.

You need some kind of overlay filter (using multiply perhaps) whose location in the overlay DOES correspond to the location in the picture you want changed.

TL;DR: You're using some color look up translation code, when you should be using some code to add an image overlay/mask.