Exemple #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
Exemple #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
Exemple #3
0
def test_wrong_type_b():
    qshift('antonini')
Exemple #4
0
def test_non_exist_qshift():
    qshift('this-does-not-exist')
Exemple #5
0
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)
Exemple #7
0
def test_qshift():
    y = colfilter(lena, qshift('qshift_a')[0])
    assert y.shape == (lena.shape[0]+1, lena.shape[1])
Exemple #8
0
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)
Exemple #10
0
def test_specific_wavelet():
    Yl, Yh = dtwavexfm2(lena, biort=biort("antonini"), qshift=qshift("qshift_06"))
Exemple #11
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
Exemple #12
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
Exemple #13
0
def test_wrong_type_b():
    qshift('antonini')
Exemple #14
0
def test_non_exist_qshift():
    qshift('this-does-not-exist')
Exemple #15
0
def test_specific_wavelet():
    Yl, Yh = dtwavexfm2(lena,
                        biort=biort('antonini'),
                        qshift=qshift('qshift_06'))
Exemple #16
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)
Exemple #17
0
def test_qshift():
    y = colfilter(lena, qshift('qshift_a')[0])
    assert y.shape == (lena.shape[0] + 1, lena.shape[1])