YuAo / Vivid

Filters and Utilities for Core Image
MIT License
479 stars 59 forks source link

YUCIRGBToneCurve filter not working as expected #4

Closed nikfil89 closed 8 years ago

nikfil89 commented 8 years ago

I'm trying to reproduce some filters from Photoshop with YUCIRGBToneCurve filter.

vividexample

As you can see with Photoshop and GPU Image effect is same but with Vivid is different.

Here is code for filter that I'm using:

let filter = CIFilter(
            name: "YUCIRGBToneCurve",
            withInputParameters:[
                "inputRedControlPoints": [CIVector(x: 0, y: 19.0 / 255.0),
                    CIVector(x: 30.0 / 255.0, y: 62.0 / 255.0),
                    CIVector(x: 82.0 / 255.0, y: 148.0 / 255.0),
                    CIVector(x: 128.0 / 255.0, y: 188.0 / 255.0),
                    CIVector(x: 145.0 / 255.0, y: 200.0 / 255.0),
                    CIVector(x: 255.0 / 255.0, y: 250.0 / 255.0)],

                "inputGreenControlPoints" : [CIVector(x: 0.0, y: 0.0),
                    CIVector(x: 48.0 / 255.0, y: 72.0 / 255.0),
                    CIVector(x: 115.0 / 255.0, y: 188.0 / 255.0),
                    CIVector(x: 160.0 / 255.0, y: 220.0 / 255.0),
                    CIVector(x: 233.0 / 255.0, y: 245.0 / 255.0),
                    CIVector(x: 255.0 / 255.0, y: 255.0 / 255.0)],

                "inputBlueControlPoints" : [CIVector(x: 0.0, y: 25.0 / 255.0),
                    CIVector(x: 35.0 / 255.0, y: 80.0 / 255.0),
                    CIVector(x: 106.0 / 255.0, y: 175.0 / 255.0),
                    CIVector(x: 151.0 / 255.0, y: 188.0 / 255.0),
                    CIVector(x: 215.0 / 255.0, y: 215.0 / 255.0),
                    CIVector(x: 240.0 / 255.0, y: 235.0 / 255.0),
                    CIVector(x: 255.0 / 255.0, y: 245.0 / 255.0)]
            ])
YuAo commented 8 years ago

Did you tried using kCIContextWorkingColorSpace key to specify a working color space when creating the CIContext object.

nikfil89 commented 8 years ago

That was the problem. Thank you.

imgyuri commented 7 years ago

I know this issue is closed, but which colorspace should you specify it to? sRGB?