The abstract class you extend to create custom image processors that can integrate with Core Image workflows.
- iOS 10.0+
- macOS 10.12+
- UIKit for Mac 13.0+Beta
- tvOS 10.0+
- Core Image
CIKernel class and its other subclasses that allow you to create new image-processing effects with the Core Image Kernel Language, the
CIImage class provides direct access to the underlying bitmap image data for a step in the Core Image processing pipeline. As such, you can create subclasses of this class to integrate other image-processing technologies—such as Metal compute shaders, Metal Performance Shaders, Accelerate vImage operations, or your own CPU-based image-processing routines—with a Core Image filter chain.
Your custom image processing operation is invoked by your subclassed image processor kernel's
process(with: method. The method can accept zero, one or more inputs: kernels that generate imagery (such as a noise or pattern generator) need no inputs, while kernels that composite source images together require multiple inputs. The
arguments dictionary allows the caller to pass in additional parameter values (such as the radius of a blur) and the
output contains the destination for your image processing code to write to.
To apply to kernel to an image, the calling side invokes the image processor's
apply(with method. The following code generates a new
CIImage object named
result which contains a thresholded version of the source image,
CIImage class is abstract; to create a custom image processor, you define a subclass of this class.
You do not directly create instances of a custom
CIImage subclass. Image processors must not carry or use state specific to any single invocation of the processor, so all methods (and accessors for readonly properties) of an image processor kernel class are class methods.
Your subclass should override at least the
process(with: method to perform its image processing.
If your image processor needs to work with a larger or smaller region of interest in the input image than each corresponding region of the output image (for example, a blur filter, which samples several input pixels for each output pixel), you should also override the
You can also override the
format method and
output property getter to customize the input and output pixel formats for your processor (for example, as part of a multi-step workflow where you extract a single channel from an RGBA image, apply an effect to that channel only, then recombine the channels).
Using a Custom Image Processor
To apply your custom image processor class to filter one or more images, call the
apply(with class method. (Do not override this method.)