MetalPetal / MetalPetal

A GPU accelerated image and video processing framework built on Metal.
https://github.com/MetalPetal/MetalPetal
MIT License
1.91k stars 246 forks source link

Lookup Filter #92

Closed alyfreym closed 5 years ago

alyfreym commented 5 years ago

Hi, I'm trying to use MTIColorLookupFilter, but the result is wrong, can you tell me what's wrong? I uploaded Color Lookup Table image. Polaroid Time Zero (Expired) 5 +

let cg = UIImage(named: "lookup")!.cgImage! let filter = MTIColorLookupFilter() filter.inputColorLookupTable = MTIImage(cgImage: cg, options: [MTKTextureLoader.Option.SRGB : true]).unpremultiplyingAlpha() filter.inputImage = inputImage

alyfreym commented 5 years ago

Result IMG_6164

YuAo commented 5 years ago

We do not currently support this kind of color lookup table.

The supported CLUT types are:

BTW, here's a tool we use to generate identity color lookup tables. https://github.com/YuAo/IdentityCLUTImageGenerator

alyfreym commented 5 years ago

Is it possible to convert it into 2D square format?

YuAo commented 5 years ago

Yes, you can just re-apply the effect to a 2d square identity color lookup table image.

BTW, you do not need to do unpremultiplyingAlpha(). The color lookup table is an opaque image you can pass the isOpaque: true to the initializer: MTIImage(cgImage: UIImage(named: "ColorLookup512")!.cgImage!, options: [.SRGB: false], isOpaque: true). This saves a render pass for you.

alyfreym commented 5 years ago

Thank you, I did it.