Ejemplo n.º 1
0
def test_bwt2d():
    # 2D test
    n = 16
    x = np.zeros((n, n))
    x[5:10, 5:10] = 1
    wbasis = 'josbiorth5'
    nscales = 3

    # Define a discretized domain
    domain = odl.FunctionSpace(odl.Rectangle([-1, -1], [1, 1]))
    nPoints = np.array([n, n])
    disc_domain = odl.uniform_discr_fromspace(domain, nPoints)
    disc_phantom = disc_domain.element(x)

    # Create the discrete wavelet transform operator.
    # Only the domain of the operator needs to be defined
    Bop = BiorthWaveletTransform(disc_domain, nscales, wbasis)
    Bop2 = InverseAdjBiorthWaveletTransform(disc_domain, nscales, wbasis)

    # Compute the discrete wavelet transform of discrete imput image
    coeffs = Bop(disc_phantom)
    coeffs2 = Bop2(disc_phantom)

    reconstruction = Bop.inverse(coeffs)
    reconstruction2 = Bop2.inverse(coeffs2)

    assert all_almost_equal(reconstruction.asarray(), x)
    assert all_almost_equal(reconstruction2.asarray(), x)
Ejemplo n.º 2
0
def test_bwt2d():
    # 2D test
    n = 16
    x = np.zeros((n, n))
    x[5:10, 5:10] = 1
    wbasis = 'josbiorth5'
    nscales = 3

    # Define a discretized domain
    domain = odl.FunctionSpace(odl.Rectangle([-1, -1], [1, 1]))
    nPoints = np.array([n, n])
    disc_domain = odl.uniform_discr_fromspace(domain, nPoints)
    disc_phantom = disc_domain.element(x)

    # Create the discrete wavelet transform operator.
    # Only the domain of the operator needs to be defined
    Bop = BiorthWaveletTransform(disc_domain, nscales, wbasis)
    Bop2 = InverseAdjBiorthWaveletTransform(disc_domain, nscales, wbasis)

    # Compute the discrete wavelet transform of discrete imput image
    coeffs = Bop(disc_phantom)
    coeffs2 = Bop2(disc_phantom)

    reconstruction = Bop.inverse(coeffs)
    reconstruction2 = Bop2.inverse(coeffs2)

    assert all_almost_equal(reconstruction.asarray(), x)
    assert all_almost_equal(reconstruction2.asarray(), x)
Ejemplo n.º 3
0
def test_bwt1d(wbasis):
    # Verify that the operator works as axpected
    # 1D test
    n = 16
    x = np.zeros(n)
    x[5:10] = 1
    nscales = 2

    # Define a discretized domain
    domain = odl.FunctionSpace(odl.Interval([-1], [1]))
    nPoints = np.array([n])
    disc_domain = odl.uniform_discr_fromspace(domain, nPoints)
    disc_phantom = disc_domain.element(x)

    # Create the discrete wavelet transform operator.
    # Only the domain of the operator needs to be defined
    Wop = BiorthWaveletTransform(disc_domain, nscales, wbasis)

    # Compute the discrete wavelet transform of discrete imput image
    coeffs = Wop(disc_phantom)

    # Compute the inverse wavelet transform
    reconstruction = Wop.inverse(coeffs)

    # Verify that reconstructions lie in correct discretized domain
    assert reconstruction in disc_domain
    assert all_almost_equal(reconstruction.asarray(), x)
Ejemplo n.º 4
0
def test_bwt1d(wbasis):
    # Verify that the operator works as axpected
    # 1D test
    n = 16
    x = np.zeros(n)
    x[5:10] = 1
    nscales = 2

    # Define a discretized domain
    domain = odl.FunctionSpace(odl.Interval([-1], [1]))
    nPoints = np.array([n])
    disc_domain = odl.uniform_discr_fromspace(domain, nPoints)
    disc_phantom = disc_domain.element(x)

    # Create the discrete wavelet transform operator.
    # Only the domain of the operator needs to be defined
    Wop = BiorthWaveletTransform(disc_domain, nscales, wbasis)

    # Compute the discrete wavelet transform of discrete imput image
    coeffs = Wop(disc_phantom)

    # Compute the inverse wavelet transform
    reconstruction = Wop.inverse(coeffs)

    # Verify that reconstructions lie in correct discretized domain
    assert reconstruction in disc_domain
    assert all_almost_equal(reconstruction.asarray(), x)