<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSImageConvolution/init(device:kernelWidth:kernelHeight:weights:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImageConvolution(im)initWithDevice:kernelWidth:kernelHeight:weights:"
  },
  "title" : "init(device:kernelWidth:kernelHeight:weights:)"
}
-->

# init(device:kernelWidth:kernelHeight:weights:)

Initializes a convolution filter.

```
init(device: any MTLDevice, kernelWidth: Int, kernelHeight: Int, weights kernelWeights: UnsafePointer<Float>)
```

## Parameters

`device`

The Metal device the filter will run on.

`kernelWidth`

The width of the kernel. Must be an odd number.

`kernelHeight`

The height of the kernel. Must be an odd number.

`kernelWeights`

A pointer to an array of `kernelWidth * kernelHeight` values to be used as the kernel. These values should be in row-major order.

## Return Value

An initialized convolution filter object.

---

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)