MPSImageConvolution
A filter that convolves an image with a given kernel of odd width and height.
Declaration
class MPSImageConvolutionOverview
Filter width and height can be either 3, 5, 7 or 9. If there are multiple channels in the source image, each channel is processed independently.
A separable convolution filter may perform better when done in two passes. . A convolution filter is separable if the ratio of filter values between all rows is constant over the whole row. For example, this edge detection filter:
[Image]
Can instead be separated into the product of two vectors, like so:
[Image]
And consequently can be done as two, one-dimensional convolution passes back to back on the same image. In this way, the number of multiplies (ignoring the fact that we could skip zeros here) is reduced from 3*3=9 to 3+3=6. There are similar savings for addition. For large filters, the savings can be profound.