Contents

CIKernel

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

Declaration

class CIKernel

Mentioned in

Overview

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

Getting a Kernel Name

Identifying the Region of Interest for the Kernel

Applying a Kernel to Filter an Image

Deprecated

Initializers

See Also

Custom Filters