<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter"
  },
  "title" : "CIFilter"
}
-->

# CIFilter

An image processor that produces an image by manipulating one or more input images or by generating new image data.

```
class CIFilter
```

## Overview

The `CIFilter` class produces a [`CIImage`](/documentation/CoreImage/CIImage) object as output. Typically, a filter takes one or more images as input. Some filters, however, generate an image based on other types of input parameters. The par`CIFilter` swift.class` object are set and retrieved through the use of key-value pairs.

You use the `CIFilter` object in conjunction with other Core Image classes, such as  `CIImage`, [`CIContext`](/documentation/CoreImage/CIContext), and [`CIColor`](/documentation/CoreImage/CIColor), to take advantage of the built-in Core Image filters when processing images, creating filter generators, or writing custom filters.

`CIFilter` objects are mutable, and thus cannot be shared safely among threads. Each thread must create its own `CIFilter` objects, but you can pass a filter’s immutable input and output `CIImage` objects between threads.

To get a quick overview of how to set up and use Core Image filters, see [Core Image Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185).

### Create type-safe filters

Core Image provides methods that create type-safe `CIFilter` instances. Use these filters to avoid run-time errors that can occur when relying on Core Image’s string-based API.

To use the type-safe API, import `CoreImage.CIFilterBuiltins`:

```swift
#import <CoreImage/CoreImage.h>
#import <CoreImage/CIFilterBuiltins.h>
```

The type-safe approach returns a non-optional filter. Because the returned filter conforms to the relevant protocol—for example, [`CIFalseColor`](/documentation/CoreImage/CIFalseColor) in the case of [`falseColor()`](/documentation/CoreImage/CIFilter-swift.class/falseColor())—the parameters are available as properties. The following creates and applies a false color filter:

```swift
- (CIImage *) falseColorImage:(CIImage*) inputImage {
    CIFilter<CIFalseColor> *falseColorFilter = CIFilter.falseColorFilter;
    falseColorFilter.color0 = [CIColor colorWithRed:1 green:1 blue:0];
    falseColorFilter.color1 = [CIColor colorWithRed:0 green:0 blue:1];
    falseColorFilter.inputImage = inputImage;
    return falseColorFilter.outputImage;
}
```

The false color filter maps luminance to a color ramp of two colors:

![Two photographs showing a flower. The image on the left shows the original version of the flower. The image on the right shows the false color version of the flower.](images/com.apple.coreimage/media-4336877@2x.png)

### Subclassing notes

You can subclass `CIFilter` in order to create custom filter effects:

- By chaining together two or more built-in Core Image filters
- By using an image-processing kernel that you write

Regardless of whether your subclass provides its effect by chaining filters or implementing its own kernel, you should:

- Declare any input parameters as properties whose names are prefixed with `input`, such as `inputImage`.
- Override the [`setDefaults()`](/documentation/CoreImage/CIFilter-swift.class/setDefaults()) methods to provide default values for any input parameters you’ve declared.
- Implement an `outputImage` method to create a new `CIImage` with your filter’s effect.

The `CIFilter` class automatically manages input parameters when archiving, copying, and deallocating filters. For this reason, your subclass must obey the following guidelines to ensure proper behavior:

- Store input parameters in instance variables whose names are prefixed with `input`.

Don’t use auto-synthesized instance variables, because their names are automatically prefixed with an underscore. Instead, synthesize the property manually. For example:

`@synthesize inputMyParameter;`

- If using manual reference counting, don’t release input parameter instance variables in your <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/dealloc> method implementation. The <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/dealloc> implementation in the `CIFilter` class uses [Key-value coding](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/KeyValueCoding.html#//apple_ref/doc/uid/TP40008195-CH25) to automatically set the values of all input parameters to `nil`.

## Topics

### Creating a filter

[`+  filterWithName:`](/documentation/CoreImage/CIFilter-swift.class/init(name:))

Creates a [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) object for a specific kind of filter.

[`init(name:withInputParameters:)`](/documentation/CoreImage/CIFilter-swift.class/init(name:withInputParameters:))

Creates a [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) object for a specific kind of filter and initializes the input values.

[`+  filterWithName:keysAndValues:`](/documentation/CoreImage/CIFilter-swift.class/filterWithName:keysAndValues:)

Creates a [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) object for a specific kind of filter and initializes the input values with a `nil`-terminated list of arguments.

### Configuring type-safe filters

Configure Core Image filters that expose their attributes as properties.

[`CIFilterProtocol`](/documentation/CoreImage/CIFilterProtocol)

The properties you use to configure a Core Image filter.

[Blur Filters](/documentation/CoreImage/blur-filters)

Apply blurs, simulate motion and zoom effects, reduce noise, and erode and dilate image regions.

[Color Adjustment Filters](/documentation/CoreImage/color-adjustment-filters)

Apply color transformations, including exposure, hue, and tint adjustments.

[Color Effect Filters](/documentation/CoreImage/color-effect-filters)

Apply color effects, including photo effects, dithering, and color maps.

[Composite Operations](/documentation/CoreImage/composite-operations)

Composite images by using a range of blend modes and compositing operators.

[Convolution Filters](/documentation/CoreImage/convolution-filters)

Produce effects such as blurring, sharpening, edge detection, translation, and embossing.

[Distortion Filters](/documentation/CoreImage/distortion-filters)

Apply distortion to images.

[Generator Filters](/documentation/CoreImage/generator-filters)

Generate barcode, geometric, and special-effect images.

[Geometry Adjustment Filters](/documentation/CoreImage/geometry-adjustment-filters)

Translate, scale, and rotate images in 2D and 3D.

[Gradient Filters](/documentation/CoreImage/gradient-filters)

Generate linear and radial gradients.

[Halftone Effect Filters](/documentation/CoreImage/halftone-effect-filters)

Simulate monochrome and CMYK halftone screens.

[Reduction Filters](/documentation/CoreImage/reduction-filters)

Create statistical information about an image.

[Sharpening Filters](/documentation/CoreImage/sharpening-filters)

Apply sharpening to images.

[Stylizing Filters](/documentation/CoreImage/stylizing-filters)

Create stylized versions of images by applying effects including pixelation and line overlays.

[Tile Effect Filters](/documentation/CoreImage/tile-effect-filters)

Produce tiled images from source images.

[Transition Filters](/documentation/CoreImage/transition-filters)

Transition between two images by using effects including page curl and swipe.

### Accessing registered filters

[`+  filterNamesInCategories:`](/documentation/CoreImage/CIFilter-swift.class/filterNames(inCategories:))

Returns an array of all published filter names that match all the specified categories.

[`+  filterNamesInCategory:`](/documentation/CoreImage/CIFilter-swift.class/filterNames(inCategory:))

Returns an array of all published filter names in the specified category.

### Registering a filter

[`+  registerFilterName:constructor:classAttributes:`](/documentation/CoreImage/CIFilter-swift.class/registerName(_:constructor:classAttributes:))

Publishes a custom filter that is not packaged as an image unit.

### Getting filter parameters and attributes

[`name`](/documentation/CoreImage/CIFilter-swift.class/name)

A name associated with a filter.

[`enabled`](/documentation/CoreImage/CIFilter-swift.class/isEnabled)

A Boolean value that determines whether the filter is enabled. Animatable.

[`attributes`](/documentation/CoreImage/CIFilter-swift.class/attributes)

A dictionary of key-value pairs that describe the filter.

[`inputKeys`](/documentation/CoreImage/CIFilter-swift.class/inputKeys)

The names of all input parameters to the filter.

[`outputKeys`](/documentation/CoreImage/CIFilter-swift.class/outputKeys)

The names of all output parameters from the filter.

[`outputImage`](/documentation/CoreImage/CIFilter-swift.class/outputImage)

Returns a [`CIImage`](/documentation/CoreImage/CIImage) object that encapsulates the operations configured in the filter.

### Setting default values

[`-  setDefaults`](/documentation/CoreImage/CIFilter-swift.class/setDefaults())

Sets all input values for a filter to default values.

### Applying a filter

[`-  apply:arguments:options:`](/documentation/CoreImage/CIFilter-swift.class/apply(_:arguments:options:))

Produces a [`CIImage`](/documentation/CoreImage/CIImage) object by applying arguments to a kernel function and using options to control how the kernel function is evaluated.

[`-  apply:`](/documentation/CoreImage/CIFilter-swift.class/apply:)

Produces a [`CIImage`](/documentation/CoreImage/CIImage) object by applying a kernel function.

### Getting localized information for registered filters

[`+  localizedNameForFilterName:`](/documentation/CoreImage/CIFilter-swift.class/localizedName(forFilterName:))

Returns the localized name for the specified filter name.

[`+  localizedNameForCategory:`](/documentation/CoreImage/CIFilter-swift.class/localizedName(forCategory:))

Returns  the localized name for the specified filter category.

[`+  localizedDescriptionForFilterName:`](/documentation/CoreImage/CIFilter-swift.class/localizedDescription(forFilterName:))

Returns the localized description of a filter for display in the user interface.

[`+  localizedReferenceDocumentationForFilterName:`](/documentation/CoreImage/CIFilter-swift.class/localizedReferenceDocumentation(forFilterName:))

Returns the location of the localized reference documentation that describes the filter.

### Creating a configuration view for a filter

[`-  viewForUIConfiguration:excludedKeys:`](/documentation/CoreImage/CIFilter-swift.class/view(forUIConfiguration:excludedKeys:))

Returns a filter view for the filter.

### Applying system tone mapping modes

[`CIDynamicRangeOption`](/documentation/CoreImage/CIDynamicRangeOption)

An enum string type that your code can use to select different System Tone Mapping modes.

### Constants

[Filter Attribute Keys](/documentation/CoreImage/filter-attribute-keys)

Attributes for a filter and its parameters.

[Data Type Attributes](/documentation/CoreImage/data-type-attributes)

Numeric data types.

[Vector Quantity Attributes](/documentation/CoreImage/vector-quantity-attributes)

Vector data types.

[Color Attribute Keys](/documentation/CoreImage/color-attribute-keys)

Color types.

[Image Attribute Keys](/documentation/CoreImage/image-attribute-keys)

Image Types

[Filter Category Keys](/documentation/CoreImage/filter-category-keys)

Categories of filters.

[Options for Applying a Filter](/documentation/CoreImage/options-for-applying-a-filter)

Options that control the application of a custom Core Image filter.

[User Interface Control Options](/documentation/CoreImage/user-interface-control-options)

Sets of controls for various user scenarios.

[User Interface Options](/documentation/CoreImage/user-interface-options)

Keys or values for the size of the input parameter controls for a filter view.

[Filter Parameter Keys](/documentation/CoreImage/filter-parameter-keys)

Keys for input parameters to filters.

[RAW Image Options](/documentation/CoreImage/raw-image-options)

Options for creating a [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) object from RAW image data.

### Deprecated

[`init(CVPixelBuffer:properties:options:)`](/documentation/CoreImage/CIFilter-swift.class/init(CVPixelBuffer:properties:options:)-7qpsv)

Creates a filter from a Core Video pixel buffer.

[`+  filterWithImageData:options:`](/documentation/CoreImage/CIFilter-swift.class/init(imageData:options:))

Creates a filter that allows the processing of RAW images.

[`+  filterWithImageURL:options:`](/documentation/CoreImage/CIFilter-swift.class/init(imageURL:options:))

Creates a filter that allows the processing of RAW images.

[`CIRAWFilterOption`](/documentation/CoreImage/CIRAWFilterOption)

[`+  serializedXMPFromFilters:inputImageExtent:`](/documentation/CoreImage/CIFilter-swift.class/serializedXMP(from:inputImageExtent:))

Serializes filter parameters into XMP form that is suitable for embedding in an image.

[`+  filterArrayFromSerializedXMP:inputImageExtent:error:`](/documentation/CoreImage/CIFilter-swift.class/filterArray(fromSerializedXMP:inputImageExtent:error:))

Returns an array of filter objects de-serialized from XMP data.

[`+  supportedRawCameraModels`](/documentation/CoreImage/CIFilter-swift.class/supportedRawCameraModels())

### Type methods

[`+  areaAlphaWeightedHistogramFilter`](/documentation/CoreImage/CIFilter-swift.class/areaAlphaWeightedHistogram())

[`+  areaBoundsRedFilter`](/documentation/CoreImage/CIFilter-swift.class/areaBoundsRed())

[`+  maximumScaleTransformFilter`](/documentation/CoreImage/CIFilter-swift.class/maximumScaleTransform())

[`+  toneMapHeadroomFilter`](/documentation/CoreImage/CIFilter-swift.class/toneMapHeadroom())

## Relationships

### Conforms To

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherited By

[`CIRAWFilter`](/documentation/CoreImage/CIRAWFilter)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)