---
title: MPSImageDilate
framework: metalperformanceshaders
role: symbol
role_heading: Class
path: metalperformanceshaders/mpsimagedilate
---

# MPSImageDilate

A filter that finds the maximum pixel value in a rectangular region by applying a dilation function.

## Declaration

```swift
class MPSImageDilate
```

## Overview

Overview An MPSImageDilate filter behaves like the MPSImageAreaMax filter, except Metal calculates the intensity at each position relative to a different value before determining which is the maximum pixel value, allowing for shaped, nonrectangular morphological probes. The code example below shows pseudocode for the calculation that returns each pixel value: for each pixel in the filter window     value = pixel[filterY][filterX] - filter[filterY*filter_width+filterX]     if( value > bestValue ){         result = value         bestValue = value     } A filter that contains all zeros is identical to an MPSImageAreaMax filter. Metal handles the center filter element as 0 to avoid causing a general darkening of the image, and it handles the edgeMode property  as MPSImageEdgeMode.clamp for this filter.

## Topics

### Initializers

- [init(coder:device:)](metalperformanceshaders/mpsimagedilate/init(coder:device:).md)

### Methods

- [init(device:kernelWidth:kernelHeight:values:)](metalperformanceshaders/mpsimagedilate/init(device:kernelwidth:kernelheight:values:).md)

### Properties

- [kernelHeight](metalperformanceshaders/mpsimagedilate/kernelheight.md)
- [kernelWidth](metalperformanceshaders/mpsimagedilate/kernelwidth.md)

## Relationships

### Inherits From

- [MPSUnaryImageKernel](metalperformanceshaders/mpsunaryimagekernel.md)

### Inherited By

- [MPSImageErode](metalperformanceshaders/mpsimageerode.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Morphological Image Filters

- [MPSImageAreaMax](metalperformanceshaders/mpsimageareamax.md)
- [MPSImageAreaMin](metalperformanceshaders/mpsimageareamin.md)
- [MPSImageErode](metalperformanceshaders/mpsimageerode.md)
