---
title: CIKernel
framework: coreimage
role: symbol
role_heading: Class
path: coreimage/cikernel
---

# CIKernel

A GPU-based image-processing routine used to create custom Core Image filters.

## Declaration

```swift
class CIKernel
```

## Mentioned in

Writing Custom Kernels

## Overview

Overview note: If your custom filter uses both color and geometry information, but does not require processing both at the same time, you can improve performance by separating your image processing code: use a CIColorKernel object for the color processing step and a CIWarpKernel object for the geometry processing step. The kernel language routine for a general-purpose filter kernel has the following characteristics: Its return type is vec4 (Core Image Kernel Language) or float4 (Metal Shading Language); that is, it returns a pixel color for the output image. It may use zero or more input images. Each input image is represented by a parameter of type sampler. A kernel routine typically produces its output by calculating source image coordinates (using the destCoord and samplerTransform functions or the samplerTransform function), samples from the source images (using the sample function), and computes a final pixel color (output using the return keyword). For example, the Metal Shading Language source below implements a filter that passes through its input image unchanged. #include <CoreImage/CoreImage.h>   extern "C" {     namespace coreimage {         float4 do_nothing(sampler src) {             return src.sample(src.coord());         }     } } The equivalent code in Core Image Kernel Language is: kernel vec4 do_nothing(sampler image) {     vec2 dc = destCoord();     return sample(image, samplerTransform(image, dc)); } The Core Image Kernel Language is a dialect of the OpenGL Shading Language. See Core Image Kernel Language Reference and Core Image Programming Guide for more details.

## Topics

### Creating a Kernel Using Metal Shading Language

- [init(functionName:fromMetalLibraryData:)](coreimage/cikernel/init(functionname:frommetallibrarydata:).md)
- [init(functionName:fromMetalLibraryData:outputPixelFormat:)](coreimage/cikernel/init(functionname:frommetallibrarydata:outputpixelformat:).md)
- [kernelNames(fromMetalLibraryData:)](coreimage/cikernel/kernelnames(frommetallibrarydata:).md)
- [kernels(withMetalString:)](coreimage/cikernel/kernels(withmetalstring:).md)

### Getting a Kernel Name

- [name](coreimage/cikernel/name.md)

### Identifying the Region of Interest for the Kernel

- [setROISelector(_:)](coreimage/cikernel/setroiselector(_:).md)

### Applying a Kernel to Filter an Image

- [apply(extent:roiCallback:arguments:)](coreimage/cikernel/apply(extent:roicallback:arguments:).md)
- [CIKernelROICallback](coreimage/cikernelroicallback.md)

### Deprecated

- [init(source:)](coreimage/cikernel/init(source:).md)
- [makeKernels(source:)](coreimage/cikernel/makekernels(source:).md)

### Initializers

- [init(string:)](coreimage/cikernel/init(string:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [CIColorKernel](coreimage/cicolorkernel.md)
- [CIWarpKernel](coreimage/ciwarpkernel.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Custom Filters

- [Writing Custom Kernels](coreimage/writing-custom-kernels.md)
- [CIColorKernel](coreimage/cicolorkernel.md)
- [CIWarpKernel](coreimage/ciwarpkernel.md)
- [CIBlendKernel](coreimage/ciblendkernel.md)
- [CISampler](coreimage/cisampler.md)
- [CIFilterShape](coreimage/cifiltershape.md)
- [CIFormat](coreimage/ciformat.md)
