Beispiel #1
0
def dwt_inv(a, d, wavelet, boundary, level=None, axis=None):
    '''
    Perform a one level inverse discrete wavelet transform.

    Result len is always 2 * len(a) - len(hkr) + 1

    Warning: if len(s) = 2k + 1, then idwt(dwt(s)) will give one element
             too much which will be zero. There is no way to know the
             parity of the original signal. It can be safely removed.
             For this reason, if len(a) is bigger than len(d) to 1, we strip
             this last element
    '''
    if len(a) == len(d) + 1:
        a = a[:-1]

    hkr = get_wavelet_obj(wavelet).get_rec_hk()
    gkr = get_wavelet_obj(wavelet).get_rec_gk()

    a_upsample = nputils.upsample(a, 2, oddeven=1, lastzero=True, axis=axis)
    d_upsample = nputils.upsample(d, 2, oddeven=1, lastzero=True, axis=axis)

    c1 = nputils.convolve(a_upsample, hkr, boundary, axis=axis, mode='valid')
    c2 = nputils.convolve(d_upsample, gkr, boundary, axis=axis, mode='valid')

    return c1 + c2
Beispiel #2
0
def dwt_inv(a, d, wavelet, boundary, level=None, axis=None):
    '''
    Perform a one level inverse discrete wavelet transform.

    Result len is always 2 * len(a) - len(hkr) + 1

    Warning: if len(s) = 2k + 1, then idwt(dwt(s)) will give one element
             too much which will be zero. There is no way to know the
             parity of the original signal. It can be safely removed.
             For this reason, if len(a) is bigger than len(d) to 1, we strip
             this last element
    '''
    if len(a) == len(d) + 1:
        a = a[:-1]

    hkr = get_wavelet_obj(wavelet).get_rec_hk()
    gkr = get_wavelet_obj(wavelet).get_rec_gk()

    a_upsample = nputils.upsample(a, 2, oddeven=1, lastzero=True, axis=axis)
    d_upsample = nputils.upsample(d, 2, oddeven=1, lastzero=True, axis=axis)

    c1 = nputils.convolve(a_upsample, hkr, boundary, axis=axis, mode='valid')
    c2 = nputils.convolve(d_upsample, gkr, boundary, axis=axis, mode='valid')

    return c1 + c2
Beispiel #3
0
def uwt_inv(a, d, wavelet, boundary, level, initial_signal=None, axis=None):
    hkr = nputils.atrou(get_wavelet_obj(wavelet).get_rec_hk(), pow(2, level))
    gkr = nputils.atrou(get_wavelet_obj(wavelet).get_rec_gk(), pow(2, level))

    c1 = nputils.convolve(a, hkr, boundary, axis=axis, mode="valid")
    c2 = nputils.convolve(d, gkr, boundary, axis=axis, mode="valid")

    return 1 / 2. * (c1 + c2)
Beispiel #4
0
def uwt(signal, wavelet, boundary, level, initial_signal=None, axis=None):
    hkd = nputils.atrou(get_wavelet_obj(wavelet).get_dec_hk(), pow(2, level))
    gkd = nputils.atrou(get_wavelet_obj(wavelet).get_dec_gk(), pow(2, level))

    a = nputils.convolve(signal, hkd, boundary, axis=axis)
    d = nputils.convolve(signal, gkd, boundary, axis=axis)

    return (a, d)
Beispiel #5
0
def uwt_inv(a, d, wavelet, boundary, level, initial_signal=None, axis=None):
    hkr = nputils.atrou(get_wavelet_obj(wavelet).get_rec_hk(), pow(2, level))
    gkr = nputils.atrou(get_wavelet_obj(wavelet).get_rec_gk(), pow(2, level))

    c1 = nputils.convolve(a, hkr, boundary, axis=axis, mode="valid")
    c2 = nputils.convolve(d, gkr, boundary, axis=axis, mode="valid")

    return 1 / 2. * (c1 + c2)
Beispiel #6
0
def uwt(signal, wavelet, boundary, level, initial_signal=None, axis=None):
    hkd = nputils.atrou(get_wavelet_obj(wavelet).get_dec_hk(), pow(2, level))
    gkd = nputils.atrou(get_wavelet_obj(wavelet).get_dec_gk(), pow(2, level))

    a = nputils.convolve(signal, hkd, boundary, axis=axis)
    d = nputils.convolve(signal, gkd, boundary, axis=axis)

    return (a, d)
Beispiel #7
0
def uimwt(signal, wavelet, boundary, level, initial_signal=None, axis=None):
    hkd = nputils.atrou(get_wavelet_obj(wavelet).get_dec_hk(), pow(2, level))

    a = nputils.convolve(signal, hkd, boundary, axis=axis, mode='same')
    a2 = nputils.convolve(a, hkd, boundary, axis=axis, mode='same')

    d = signal - a2

    return (a, d)
Beispiel #8
0
def uimwt(signal, wavelet, boundary, level, initial_signal=None, axis=None):
    hkd = nputils.atrou(get_wavelet_obj(wavelet).get_dec_hk(), pow(2, level))

    a = nputils.convolve(signal, hkd, boundary, axis=axis, mode='same')
    a2 = nputils.convolve(a, hkd, boundary, axis=axis, mode='same')

    d = signal - a2

    return (a, d)
Beispiel #9
0
def dwt(signal, wavelet, boundary, level=None, initial_signal=None, axis=None):
    '''
    Perform a one level discrete wavelet transform.

    Result is len k + l + 1 if len(s) = 2k  and len(hkd) = 2l
        it is len k + l if len(s) = 2k + 1

    '''
    hkd = get_wavelet_obj(wavelet).get_dec_hk()
    gkd = get_wavelet_obj(wavelet).get_dec_gk()

    a_conv = nputils.convolve(signal, hkd, boundary, axis=axis)
    d_conv = nputils.convolve(signal, gkd, boundary, axis=axis)

    a = nputils.downsample(a_conv, 2, oddeven=1, axis=axis)
    d = nputils.downsample(d_conv, 2, oddeven=1, axis=axis)

    return (a, d)
Beispiel #10
0
def dwt(signal, wavelet, boundary, level=None, initial_signal=None, axis=None):
    '''
    Perform a one level discrete wavelet transform.

    Result is len k + l + 1 if len(s) = 2k  and len(hkd) = 2l
        it is len k + l if len(s) = 2k + 1

    '''
    hkd = get_wavelet_obj(wavelet).get_dec_hk()
    gkd = get_wavelet_obj(wavelet).get_dec_gk()

    a_conv = nputils.convolve(signal, hkd, boundary, axis=axis)
    d_conv = nputils.convolve(signal, gkd, boundary, axis=axis)

    a = nputils.downsample(a_conv, 2, oddeven=1, axis=axis)
    d = nputils.downsample(d_conv, 2, oddeven=1, axis=axis)

    return (a, d)