How to apply LUT filter?

49 views Asked by At

I want to apply a LUT-filter on a image, and I have LUT image size are 256x16 and the size is 256x16. It will working fine for LUT image size are 512x512. And I am using GPUImage Framework for applying filter. If you know how to apply LUT 256x16 image using GPUImage Framework or other way please help me.

let lutImage = UIImage.init(named: "lut2.png") ?? UIImage()
imgPreview.image = setFilter(lutImage, image: imgPreview.image!)

public extension PlatformImageType {
    func filterWithOperation<T:ImageProcessingOperation>(_ operation:T) -> PlatformImageType? {
    return filterWithPipeline{input, output in
        input --> operation --> output
    }
}

func filterWithPipeline(_ pipeline:(PictureInput, PictureOutput) -> ()) -> PlatformImageType? {
    let picture = PictureInput(image:self)
    var outputImage:PlatformImageType?
    let pictureOutput = PictureOutput()
    pictureOutput.onlyCaptureNextFrame = true
    pictureOutput.imageAvailableCallback = {image in
        outputImage = image
    }
    pipeline(picture, pictureOutput)
    picture.processImage(synchronously:true)
    return outputImage?.fixOrientation()
}
}
0

There are 0 answers