Example #1
0
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
Example #2
0
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
Example #3
0
def test_legall():
    h0o, g0o, h1o, g1o = biort('legall')
    assert h0o.shape[0] == 5
    assert g0o.shape[0] == 3
    assert h1o.shape[0] == 3
    assert g1o.shape[0] == 5
Example #4
0
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
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)
Example #5
0
def test_biort():
    y = colfilter(lena, biort('antonini')[0])
    assert y.shape == lena.shape
Example #6
0
def test_legall():
    h0o, g0o, h1o, g1o = biort('legall')
    assert h0o.shape[0] == 5
    assert g0o.shape[0] == 3
    assert h1o.shape[0] == 3
    assert g1o.shape[0] == 5
Example #7
0
def test_wrong_type_a():
    biort('qshift_06')
Example #8
0
def test_antonini():
    h0o, g0o, h1o, g1o = biort('antonini')
    assert h0o.shape[0] == 9
    assert g0o.shape[0] == 7
    assert h1o.shape[0] == 7
    assert g1o.shape[0] == 9
Example #9
0
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
Example #10
0
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
Example #11
0
def test_wrong_type_a():
    biort('qshift_06')
Example #12
0
def test_non_exist_biort():
    biort('this-does-not-exist')
Example #13
0
def test_antonini():
    h0o, g0o, h1o, g1o = biort('antonini')
    assert h0o.shape[0] == 9
    assert g0o.shape[0] == 7
    assert h1o.shape[0] == 7
    assert g1o.shape[0] == 9
Example #14
0
def test_near_sym_a():
    h0o, g0o, h1o, g1o = biort('near_sym_b')
    assert h0o.shape[0] == 13
    assert g0o.shape[0] == 19
    assert h1o.shape[0] == 19
    assert g1o.shape[0] == 13
Example #15
0
def test_near_sym_a():
    h0o, g0o, h1o, g1o = biort('near_sym_a')
    assert h0o.shape[0] == 5
    assert g0o.shape[0] == 7
    assert h1o.shape[0] == 7
    assert g1o.shape[0] == 5
Example #16
0
def test_near_sym_a():
    h0o, g0o, h1o, g1o = biort('near_sym_a')
    assert h0o.shape[0] == 5
    assert g0o.shape[0] == 7
    assert h1o.shape[0] == 7
    assert g1o.shape[0] == 5
Example #17
0
def test_near_sym_a():
    h0o, g0o, h1o, g1o = biort('near_sym_b')
    assert h0o.shape[0] == 13
    assert g0o.shape[0] == 19
    assert h1o.shape[0] == 19
    assert g1o.shape[0] == 13
Example #18
0
def test_specific_wavelet():
    Yl, Yh = dtwavexfm2(lena, biort=biort("antonini"), qshift=qshift("qshift_06"))
Example #19
0
def test_non_exist_biort():
    biort('this-does-not-exist')
Example #20
0
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
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)
Example #21
0
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)
Example #22
0
def test_biort():
    y = colfilter(lena, biort('antonini')[0])
    assert y.shape == lena.shape