高斯二维滤波器可分离性的优缺点是什么?

信息处理 图像处理 过滤器 高斯 过滤 svd
2022-01-25 12:19:02

我知道高斯滤波器的可分离性提高了计算复杂度O(L2NM)O((LNM). 这如何真正反映我的程序?我想与不可分离的情况相比,卷积所需的 for 循环数更少?什么真正的缺点?

1个回答

假设最简单的情况是正方形图像x[n,m]大小的ñ×ñ和一个方形过滤器内核H[n,]大小的×, 原始 2D 卷积以生成裁剪后的输出图像是的[n,]大小的ñ×ñ需要大约ñ2×2MAC。

之间的原始二维卷积X[n,]和过滤器H[n,]是通过使用两个 for 循环来遍历每个输出像素和两个额外的 for 循环来在该像素位置执行 2D 卷积来实现的。因此总共需要 4 个嵌套的 for 循环;复杂性(ñ22)

当过滤内核H[n,]可分离的,例如H[n,]=F[n]G[],那么在这种情况下,图像之间的卷积X[n,]和过滤器H[n,]可以通过以下方法在没有原始 2D 卷积和的情况下执行:

  1. 首先,在列之间执行一维卷积X[n,]和一维滤波器F[n],这需要大约ñ×MACs 来完成。应该对每列执行此操作X[n,]通过沿其水平方向前进,ñ许多,列。因此共有ñ××ñMAC 将需要完成第一步以生成中间图像w[n,m]
  2. Then, apply the similar algorithm, with the filter g[m] and rows of the intermediate image w[:,m], which will require similar number of MACs as N×M×N.

Hence as a total you will need about 2N2M MACs for the separable implementation of the 2D convolution. The actual number depends on the cropping type you apply. Thus a complexity of about O(N2M) is attained.

It can be seen that, to implement the separable convolution algorithm, you will only need 3 nested for loops, which is where the gain comes from.

The main advantage of separable filtering is quite clear; much reduced computational cost. In fact even the 2D-FFT algorithm makes use of it as the 2D-DFT kernel is separable.

Another advantage is that since there are less number of MACs involved to produce the same output compared to the raw 2D convolution, it's less prone to numerical issues and likely to produce more accurate results.

A disadvantage of separation is that it requires an extra ram memory to store the intermediate image, which can be a concern in certain applications.