<!--
{
  "documentType" : "article",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/2d-convolution",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "2D convolution"
}
-->

# 2D convolution

Perform convolution operations on matrices of real data.

## Discussion

Use the functions in this group to apply a convolution kernel to a 2D matrix. The vDSP library provides functions to convolve with fixed-sized kernels and kernels with an arbitrary size.

> Important:
> The functions in this group don’t support in-place operation.

## Topics

### Fixed-Size Kernel

[`convolve(_:rowCount:columnCount:with3x3Kernel:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with3x3Kernel:)-1r5oa)

Returns the 2D convolution of a double-precision vector with a 3 x 3 kernel.

[`convolve(_:rowCount:columnCount:with3x3Kernel:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with3x3Kernel:)-7qjgw)

Returns the 2D convolution of a single-precision vector with a 3 x 3 kernel.

[`convolve(_:rowCount:columnCount:with3x3Kernel:result:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with3x3Kernel:result:)-34k76)

Calculates the 2D convolution of a double-precision vector with a 3 x 3 kernel.

[`convolve(_:rowCount:columnCount:with3x3Kernel:result:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with3x3Kernel:result:)-2worq)

Calculates the 2D convolution of a single-precision vector with a 3 x 3 kernel.

[`convolve(_:rowCount:columnCount:with5x5Kernel:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with5x5Kernel:)-7cvh9)

Returns the 2D convolution of a double-precision vector with a 5 x 5 kernel.

[`convolve(_:rowCount:columnCount:with5x5Kernel:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with5x5Kernel:)-101d6)

Returns the 2D convolution of a single-precision vector with a 5 x 5 kernel.

[`convolve(_:rowCount:columnCount:with5x5Kernel:result:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with5x5Kernel:result:)-g68r)

Calculates the 2D convolution of a double-precision vector with a 5 x 5 kernel.

[`convolve(_:rowCount:columnCount:with5x5Kernel:result:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:with5x5Kernel:result:)-76h85)

Calculates the 2D convolution of a single-precision vector with a 5 x 5 kernel.

[`vDSP_f3x3`](/documentation/Accelerate/vDSP_f3x3)

Filters a single-precision image by performing a 2D convolution with a 3 x 3 kernel.

[`vDSP_f3x3D`](/documentation/Accelerate/vDSP_f3x3D)

Filters a double-precision image by performing a 2D convolution with a 3 x 3 kernel.

[`vDSP_f5x5`](/documentation/Accelerate/vDSP_f5x5)

Filters a single-precision image by performing a 2D convolution with a 5 x 5 kernel.

[`vDSP_f5x5D`](/documentation/Accelerate/vDSP_f5x5D)

Filters a double-precision image by performing a 2D convolution with a 5 x 5 kernel.

### Arbitrary-Size Kernel

[`convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:)-1sswe)

Returns the 2D convolution of a double-precision vector with an arbitrarily sized kernel.

[`convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:)-267yl)

Returns the 2D convolution of a single-precision vector with an arbitrarily sized kernel.

[`convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:result:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:result:)-4211m)

Calculates the 2D convolution of a double-precision vector with an arbitrarily sized kernel.

[`convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:result:)`](/documentation/Accelerate/vDSP/convolve(_:rowCount:columnCount:withKernel:kernelRowCount:kernelColumnCount:result:)-5hiro)

Calculates the 2D convolution of a single-precision vector with an arbitrarily sized kernel.

[`vDSP_imgfir`](/documentation/Accelerate/vDSP_imgfir)

Filters a single-precision image by performing a 2D convolution with an arbitrarily sized kernel.

[`vDSP_imgfirD`](/documentation/Accelerate/vDSP_imgfirD)

Filters a double-precision image by performing a 2D convolution with an arbitrarily sized kernel.



---

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)