计算细节系数而不进行下采样

问题描述 投票:0回答:1

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

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

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

python numpy image-processing signal-processing wavelet
1个回答
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)
© www.soinside.com 2019 - 2024. All rights reserved.