pierrepaleo/pypwt

Do you have a plan to support custom wavelets?

Closed this issue · 2 comments

Thank you for this excellent project. But I found that it does not support custom wavelet which is supported in PWDT. Do you have a plan to support custom wavelets?

Hi @richardxdh, would PR #13 work for you ?

Example usage:

from pycudwt import Wavelets
# Build an initial separable wavelets transform object. Filters will be re-defined below
W = Wavelets(img, "haar", 1, 1)

# Define a custom filter bank, here LeGall 5/3 wavelet
legall53_l = np.array([0.0, -1.0/8, 2.0/8, 6.0/8, 2.0/8, -1.0/8])
legall53_h = np.array([0, -0.5, 1.0, -0.5, 0.0, 0])
legall53_il = np.array([0,  0.5,  1,  0.5,  0,  0])
legall53_ih = np.array([0,  -1.0/8,  -2.0/8,  6.0/8,  -2.0/8,  -1.0/8])

W.set_wavelets_filters(
    "legall53",
    legall53_l,
    legall53_h,
    legall53_il,
    legall53_ih,
)

# Test impulse response 
def dirac(shape):
    d = np.zeros(shape, dtype="f")
    d[shape[0]//2, shape[1]//2] = 1
    return d

W.set_image(dirac(img.shape))
W.forward()

# print the wavelets transform appcoeff near the center
print(W.coeffs[0][128-1:128+2, 128-1:128+2])
# compare with filter response
print(np.outer(legall53_l, legall53_l)[1::2, 1::2])

@pierrepaleo Thank you for responding immediately, it works for me now.