def test_simple_level_4_recon_custom_wavelets(): # Test for perfect reconstruction with 3 levels b = biort('legall') q = qshift('qshift_06') Yl, Yh = dtwavexfm3(ellipsoid, 4, biort=b, qshift=q) ellipsoid_recon = dtwaveifm3(Yl, Yh, biort=b, qshift=q) assert ellipsoid.size == ellipsoid_recon.size assert np.max(np.abs(ellipsoid - ellipsoid_recon)) < TOLERANCE
def test_wrong_type_b(): qshift('antonini')
def test_non_exist_qshift(): qshift('this-does-not-exist')
def test_qshift_d(): coeffs = qshift('qshift_d') assert len(coeffs) == 8 for v in coeffs: assert v.shape[0] == 18
from dtcwt import dtwavexfm3, dtwaveifm3, biort, qshift # Specify details about sphere and grid size GRID_SIZE = 128 SPHERE_RAD = int(0.45 * GRID_SIZE) + 0.5 # Compute an image of the sphere grid = np.arange(-(GRID_SIZE >> 1), GRID_SIZE >> 1) X, Y, Z = np.meshgrid(grid, grid, grid) r = np.sqrt(X * X + Y * Y + Z * Z) sphere = (0.5 + np.clip(SPHERE_RAD - r, -0.5, 0.5)).astype(np.float32) # Specify number of levels and wavelet family to use nlevels = 2 b = biort('near_sym_a') q = qshift('qshift_a') # Form the DT-CWT of the sphere. We use discard_level_1 since we're # uninterested in the inverse transform and this saves us some memory. Yl, Yh = dtwavexfm3(sphere, nlevels, b, q, discard_level_1=True) # Plot maxima figure(figsize=(8, 8)) ax = gcf().add_subplot(1, 1, 1, projection='3d') ax.set_aspect('equal') ax.view_init(35, 75) # Plot unit sphere +ve octant thetas = np.linspace(0, np.pi / 2, 10) phis = np.linspace(0, np.pi / 2, 10)
def test_qshift(): y = colfilter(lena, qshift('qshift_a')[0]) assert y.shape == (lena.shape[0]+1, lena.shape[1])
from dtcwt import dtwavexfm3, dtwaveifm3, biort, qshift # Specify details about sphere and grid size GRID_SIZE = 128 SPHERE_RAD = int(0.45 * GRID_SIZE) + 0.5 # Compute an image of the sphere grid = np.arange(-(GRID_SIZE>>1), GRID_SIZE>>1) X, Y, Z = np.meshgrid(grid, grid, grid) r = np.sqrt(X*X + Y*Y + Z*Z) sphere = (0.5 + np.clip(SPHERE_RAD-r, -0.5, 0.5)).astype(np.float32) # Specify number of levels and wavelet family to use nlevels = 2 b = biort('near_sym_a') q = qshift('qshift_a') # Form the DT-CWT of the sphere. We use discard_level_1 since we're # uninterested in the inverse transform and this saves us some memory. Yl, Yh = dtwavexfm3(sphere, nlevels, b, q, discard_level_1=True) # Plot maxima figure(figsize=(8,8)) ax = gcf().add_subplot(1,1,1, projection='3d') ax.set_aspect('equal') ax.view_init(35, 75) # Plot unit sphere +ve octant thetas = np.linspace(0, np.pi/2, 10) phis = np.linspace(0, np.pi/2, 10)
def test_specific_wavelet(): Yl, Yh = dtwavexfm2(lena, biort=biort("antonini"), qshift=qshift("qshift_06"))
def test_simple_custom_filter(): vec = np.random.rand(630) Yl, Yh = dtwavexfm(vec, 4, biort('legall'), qshift('qshift_06')) vec_recon = dtwaveifm(Yl, Yh, biort('legall'), qshift('qshift_06')) assert np.max(np.abs(vec_recon - vec)) < TOLERANCE
def test_specific_wavelet(): Yl, Yh = dtwavexfm2(lena, biort=biort('antonini'), qshift=qshift('qshift_06'))
def test_reconstruct_custom_filter(): # Reconstruction up to tolerance Yl, Yh = dtwavexfm2(lena, 4, biort('legall'), qshift('qshift_06')) lena_recon = dtwaveifm2(Yl, Yh, biort('legall'), qshift('qshift_06')) assert np.all(np.abs(lena_recon - lena) < TOLERANCE)
def test_qshift(): y = colfilter(lena, qshift('qshift_a')[0]) assert y.shape == (lena.shape[0] + 1, lena.shape[1])