【问题标题】:Computing the Detail Coeffiecients without Downsampling在不下采样的情况下计算细节系数
【发布时间】:2019-08-28 11:14:59
【问题描述】:

小波变换允许我们计算信号或图像的细节系数。它还在每个分解级别对图像进行下采样。

我想在不进行下采样的情况下计算细节系数。我想使用低通滤波器 G 来提取细节系数,如正交镜像滤波器描述的减去下采样。但是,我只有一维的过滤器:[-1/sqrt(2), 1/sqrt(2)]

据我了解,我可以先将 G 应用于图像的行,然后再应用于列。我如何在 Numpy 中执行这种乘法?我的图片大小为768x768。

【问题讨论】:

  • 这个一维数组的大小是多少? [-1/sqrt(2), 1/sqrt(2)]
  • @kmario23 (2,)

标签: python numpy image-processing signal-processing wavelet


【解决方案1】:

如果我正确理解您的问题,那么我们可以利用广播来做到这一点,但在此之前,我们必须平铺我们的初始过滤器以匹配我们图像的一个尺寸。幸运的是,这里的图像是方形图像。所以,很多事情变得容易了:

In [70]: filter_ = np.array([-1/np.sqrt(2), 1/np.sqrt(2)])

In [71]: filter_
Out[71]: array([-0.70710678,  0.70710678])

# tile the initial array to match the dimensions of image
In [72]: filter_1d = np.tile(filter_, 768//2)

In [73]: filter_1d.shape
Out[73]: (768,)

In [74]: img = np.random.random_sample((768, 768))

# apply the filter on the image
In [76]: filtered = np.multiply(img, filter_1d)

In [77]: filtered.shape
Out[77]: (768, 768)

【讨论】:

  • 这在哪个方向上相乘?行还是列?
  • 由于我们平铺它,这将沿第二维广播。但是,乘法是逐元素的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-06
  • 2021-11-10
相关资源
最近更新 更多