A filter that finds the maximum pixel value in a rectangular region centered around each pixel in the source image.
SDKs
- iOS 9.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- Metal Performance Shaders
Declaration
class MPSImageDilate : MPSUnary Image Kernel
Overview
An MPSImage
filter behaves like the MPSImage
filter, except that the intensity at each position is calculated relative to a different value before determining which is the maximum pixel value, allowing for shaped, non-rectangular morphological probes.
Listing 1 shows pseudocode for the calculation used to return each pixel value.
MPSImageDilate Pseudocode
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 MPSImage
filter. The center filter element is assumed to be 0
to avoid causing a general darkening of the image. The edge
property value is assumed to always be MPSImage
for this filter.