<!--
{
  "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/MPSImageDilate/init(device:kernelWidth:kernelHeight:values:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImageDilate(im)initWithDevice:kernelWidth:kernelHeight:values:"
  },
  "title" : "init(device:kernelWidth:kernelHeight:values:)"
}
-->

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

Initializes the kernel with a specified width, height, and weight values.

```
init(device: any MTLDevice, kernelWidth: Int, kernelHeight: Int, values: 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.

`values`

The set of values to use as the dilate probe. The values are copied into the filter. To avoid image lightening or darkening, the center value should be `0.0f`.

## Return Value

Returns an initialized kernel object with specific width, height, and weight values.

## Discussion

Each dilate shape probe defines a 3D surface of values. These are arranged in order left to right, then top to bottom in a 1D array. (`values[kernelWidth*y+x] = probe[y][x]`)

Values should be generally be in the range `[0,1]` with the center pixel tending towards `0` and edges towards `1`. However, any numerical value is allowed. Calculations are subject to the usual floating-point rounding error.

---

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)