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

# convolutionRGB3X3()

Applies a convolution 3 x 3 filter to the `RGB` components of an image.

```
class func convolutionRGB3X3() -> any CIFilter & CIConvolution
```

## Return Value

The convolved image.

## Discussion

This method applies a 3 x 3 convolution to the `RGB` components of an image. The effect uses a 3 x 3 area surrounding an input pixel, the pixel itself, and those within a distance of 1 pixel horizontally and vertically. This filter differs from the [`convolution3X3()`](/documentation/CoreImage/CIFilter-swift.class/convolution3X3()) filter, which processes all of the color components including the alpha component.

The convolution-RGB 3 x 3 filter uses the following properties:

- `bias`: A `float` representing the value that’s added to each output pixel.
- `weights`: A [`CIVector`](/documentation/CoreImage/CIVector) representing the convolution kernel.
- `inputImage`: A [`CIImage`](/documentation/CoreImage/CIImage) containing the image to process.

> Note:
> When using a nonzero `bias` value, the output image has an infinite extent. You should crop the output image before attempting to render it.

The following code creates a filter that sharpens the input image:

```swift
func convolutionRGB3X3(inputImage: CIImage) -> CIImage {
    let convolutionFilter = CIFilter.convolutionRGB3X3()
    convolutionFilter.inputImage = inputImage
    let kernel = CIVector(values: [
        0, -2, 0,
        -2, 9, -2,
        0, -2, 0
    ], count: 9)
    convolutionFilter.weights = kernel
    convolutionFilter.bias = 0.0
    return convolutionFilter.outputImage!
}
```

![Two images arranged horizontally. The left image is of a modern building with horizontal concrete beams and large tinted windows. The right image shows the result of applying the convolution RGB 3 x 3 filter with a kernel that sharpens the image. Edges and fine detail in the image are emphasized.](images/com.apple.coreimage/media-4407321@2x.png)

---

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)