---
title: "init(device:kernelWidth:kernelHeight:weights:)"
framework: metalperformanceshaders
role: symbol
role_heading: Initializer
path: "metalperformanceshaders/mpsimageconvolution/init(device:kernelwidth:kernelheight:weights:)"
---

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

Initializes a convolution filter.

## Declaration

```swift
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

Return Value An initialized convolution filter object.
