<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIKernel/apply(extent:roiCallback:arguments:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIKernel(im)applyWithExtent:roiCallback:arguments:"
  },
  "title" : "apply(extent:roiCallback:arguments:)"
}
-->

# apply(extent:roiCallback:arguments:)

Creates a new image using the kernel and specified arguments.

```
func apply(extent: CGRect, roiCallback callback: @escaping CIKernelROICallback, arguments args: [Any]) -> CIImage?
```

## Parameters

`extent`

The extent of the output image.

`callback`

A block or closure that computes the region of interest for a given rectangle of destination image pixels. See [`CIKernelROICallback`](/documentation/CoreImage/CIKernelROICallback).

`args`

An array of arguments to pass to the kernel routine. The type of each object in the array must be compatible with the corresponding parameter declared in the kernel routine source code. For details, see [Core Image Kernel Language Reference](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CIKernelLangRef/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004397).

## Return Value

A new image object describing the result of applying the kernel.

## Discussion

This method is analogous to the [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) method [`apply(_:arguments:options:)`](/documentation/CoreImage/CIFilter-swift.class/apply(_:arguments:options:)), but it does not require construction of a [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) object, and it allows you to specify a callback for determining the kernel’s region of interest as a block or closure. As with the similar [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) method, calling this method does not execute the kernel code—filters and their kernel code are evaluated only when rendering a final output image.

When applying a filter kernel, the region of interest (ROI) is the area of source image pixels that must be processed to produce a given area of destination image pixels. For a more detailed definition, see [The Region of Interest](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_advanced_concepts/ci.advanced_concepts.html#//apple_ref/doc/uid/TP30001185-CH9-SW12). Core Image calls your `callback` block or closure to determine the ROI when rendering the filter output. Core Image automatically splits large images into smaller tiles for rendering, so your callback may be called multiple times.

---

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)