I recently upgraded to Xcode 10.2 and my CIColorKernel code does not work anymore. CIColorKernel function returns a nil and I get the warning - 'init(source:)' was deprecated in OS X 10.14: Core Image Kernel Language API deprecated.
Is Metal Shading Language the only available alternative to CIColorKernel? Looks like MSL require creating a separate file for the custom filter and I wanted to check if there are any better options.
// Create custom Kernel to replace gray color with black or white.
//Kernel is nil because 'init(source:)' was deprecated in OS X 10.14.
let Kernel = CIColorKernel( source:
"kernel vec4 replaceGrayWithBlackOrWhite(__sample grayImage) {" +
"if (s.r > 0.25 && s.g > 0.25 && s.b > 0.25) {" +
" return vec4(0.0,0.0,0.0,1.0);" +
"} else {" +
" return vec4(1.0,1.0,1.0,1.0);" +
"}" +
"}"
)
// Apply the filter
let blackAndWhiteImage = replaceGrayKernel?.apply(extent: ((grayImage?.extent)! ), arguments: [grayImage as Any])