我正在尝试使用任意阶次的Battle-Lemarié样条小波通过离散小波变换(DWT)分析某些数据。该分析将在二维图像中用于降噪,计算一阶和二阶导数以及从每个小波尺度中提取相关信息。由于我不是数学家,因此我还必须确保这些小波是正交的。

我想知道是否有人也尝试使用这些小波家族,尤其是在Python中。

最佳答案

到目前为止,我查看了一些参考资料,并且在Mallat的“信号处理的小波导览”(2008,表7.1)中发现了线性样条(m=1)和三次样条()。

使用Wasilewski的m=3 Python库,我创建了两个共轭镜像过滤器
在多分辨率近似中使用。下图说明了三次样条缩放函数ϕ和小波ψ的结果:



生成该图的代码如下,

import numpy
import pywt
from matplotlib import pyplot as plt

class wavelet_BattleLamarie(object):
    _filter_bank = None

    def __init__(self, m=1):
        # Sets the conjugate low pass reconstruction filter h[n] for linear
        # splines (m=1) and cubic splines (m=3) as in Mallat (2008, table 7.1).
        #
        # REFERENCES:
        # Mallat, S. A wavelet tour of signal processing: The sparse way
        # Academic Press, 2008, 805.
        #
        if m == 1:
            rec_lo = numpy.array([-0.000122686, -0.000224296, 0.000511636,
                0.000923371, -0.002201945, -0.003883261, 0.009990599,
                0.016974805, -0.051945337, -0.06910102, 0.39729643,
                0.817645956, 0.39729643, -0.06910102, -0.051945337,
                0.016974805, 0.009990599, -0.003883261, -0.002201945,
                0.000923371, 0.000511636, -0.000224296, -0.000122686])
        elif m == 3:
            rec_lo = numpy.array([0.000146098, -0.000232304, -0.000285414,
                0.000462093, 0.000559952, -0.000927187, -0.001103748,
                0.00188212, 0.002186714, -0.003882426, -0.00435384,
                0.008201477, 0.008685294, -0.017982291, -0.017176331,
                0.042068328, 0.032080869, -0.110036987, -0.050201753,
                0.433923147, 0.766130398, 0.433923147, -0.050201753,
                -0.110036987, 0.032080869, 0.042068328, -0.017176331,
                -0.017982291, 0.008685294, 0.008201477, -0.00435384,
                -0.003882426, 0.002186714, 0.00188212, -0.001103748,
                -0.000927187, 0.000559952, 0.000462093, -0.000285414,
                -0.000232304, 0.000146098])
        else:
            raise ValueError('Order %d not implemented yet.' % (n))

        # Determines the remaining conjugate mirror filters from the low pass
        # reconstruction filter h[n]
        dec_lo = rec_lo[::-1]
        rec_hi = pywt.functions.qmf(rec_lo)
        dec_hi = rec_hi[::-1]
        #
        self._filter_bank = (dec_lo, dec_hi, rec_lo, rec_hi)
        return

    @property
    def filter_bank(self):
        return self._filter_bank

w = pywt.Wavelet('bspline3', filter_bank=wavelet_BattleLamarie(m=3))
#w.name = 'Battle-Lamarie of order 1'
#w.short_family_name = 'B-spline'
#w.family_name = 'Battle-Lamarie'
w.orthogonal = True
w.biorthogonal = False
#w.symmetry = 'symmetric'


###############################################################################
# NICE PLOTS
###############################################################################
plt.close('all')
plt.ion()

phi, psi, x = w.wavefun()

fig = plt.figure(figsize=[8, 4])
ax = fig.add_subplot(1, 2, 1)
ax.plot(x, phi, 'k-')
ax.set_title(r'$\phi$')
bx = fig.add_subplot(1, 2, 2)
bx.plot(x, psi, 'k-')
bx.set_title(r'$\psi$')
plt.tight_layout()


但是,我仍然对以任何顺序实现Battle-Lemarié样条小波感兴趣,即m = {1,2,3,...}。有没有更优雅的方式来创建这些小波?也许有一个较小的滤波器组?

关于python - Python中任何顺序的Battle-Lemarié样条小波基,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18863927/

10-12 22:26