def test_ODOG(stimulus, rhs_bank, output_odog_matlab):
    # RHS convolution with python RHS filters matches matlab output
    filters_output = np.empty(rhs_bank.shape)
    for i in range(rhs_bank.shape[0]):
        for j in range(rhs_bank.shape[1]):
            filters_output[i, j,
                           ...] = RHS_filters.ourconv(stimulus, rhs_bank[i, j,
                                                                         ...])

    output = RHS_filters.odog_normalize(filters_output)
    assert np.allclose(output, output_odog_matlab)
def test_RHSconv_RHS(matlab_filteroutput, stimulus, rhs_bank):
    # RHS convolution with python RHS filters matches matlab output
    filters_output = np.empty(rhs_bank.shape)
    for i in range(rhs_bank.shape[0]):
        for j in range(rhs_bank.shape[1]):
            filters_output[i, j,
                           ...] = RHS_filters.ourconv(stimulus, rhs_bank[i, j,
                                                                         ...])

    assert np.allclose(matlab_filteroutput, filters_output)
def test_RHSconv_matlab(matlab_filteroutput, matlab_bank, stimulus):
    # RHS convolution with matlab filters matches matlab output
    filters_output = np.empty(matlab_bank.shape)
    for i in range(matlab_bank.shape[0]):
        for j in range(matlab_bank.shape[1]):
            filters_output[i, j,
                           ...] = RHS_filters.ourconv(stimulus,
                                                      matlab_bank[i, j, ...])

    assert np.allclose(matlab_filteroutput, filters_output)
Esempio n. 4
0
def test_conv_apply(rhs_bank, stimulus):
    o_conv = np.empty(rhs_bank.shape)
    o_apply = np.empty(rhs_bank.shape)
    for i in range(rhs_bank.shape[0]):
        for j in range(rhs_bank.shape[1]):
            f = rhs_bank[i, j]
            o_conv[i, j, ...] = RHS_filters.ourconv(stimulus, f)
            o_apply[i, j, ...] = filters.apply(stimulus, f, pad=True)

    assert np.allclose(o_conv, o_apply)
Esempio n. 5
0
def test_circular_Gaussian():
    sigma1 = 2
    sigmas = np.array([1, 1]) * sigma1
    f = multyscale.filters.gaussian2d(x, y, (sigmas[0], sigmas[1]))
    f = f / f.sum()
    f_2 = RHS_filters.d2gauss(
        shape[0], sigmas[0] * 32, shape[1], sigmas[0] * 32, 0
    )

    plt.subplot(2, 2, 1)
    plt.imshow(f)
    plt.subplot(2, 2, 2)
    plt.imshow(f_2)
    plt.subplot(2, 2, 3)
    plt.plot(f[512, :])
    plt.subplot(2, 2, 4)
    plt.plot(f_2[512, :])

    assert np.allclose(f, f_2)
Esempio n. 6
0
def test_ODOG():
    orientation = 150
    sigma3 = 2
    sigmas = np.array([[1, 1], [1, 2]]) * sigma3
    rhs_odog = RHS_filters.odog(
        shape[0], shape[1], sigma3 * 32, orientation=orientation
    )
    multy_odog = multyscale.filters.odog(
        x, y, sigmas, orientation=(orientation, orientation)
    )

    plt.subplot(2, 2, 1)
    plt.imshow(rhs_odog)
    plt.subplot(2, 2, 2)
    plt.imshow(multy_odog)
    plt.subplot(2, 2, 3)
    plt.plot(rhs_odog[512, :])
    plt.subplot(2, 2, 4)
    plt.plot(multy_odog[512, :])

    assert np.allclose(rhs_odog, multy_odog)
Esempio n. 7
0
def test_elliptical_Gaussian():
    sigma1 = 2
    orientation = 40
    sigma2 = 2 * sigma1
    sigmas = np.array([1, 1]) * np.array([sigma1, sigma2])
    f = multyscale.filters.gaussian2d(
        x, y, (sigmas[0], sigmas[1]), orientation=orientation
    )
    f = f / f.sum()
    f_2 = RHS_filters.d2gauss(
        shape[0], sigmas[0] * 32, shape[1], sigmas[1] * 32, orientation
    )

    plt.subplot(2, 2, 1)
    plt.imshow(f)
    plt.subplot(2, 2, 2)
    plt.imshow(f_2)
    plt.subplot(2, 2, 3)
    plt.plot(f[512, :])
    plt.subplot(2, 2, 4)
    plt.plot(f_2[512, :])

    assert np.allclose(f, f_2)
Esempio n. 8
0
def rhs_bank():
    # Create RHS filterbank from Python transplation
    return RHS_filters.filterbank()
Esempio n. 9
0
# %%
import multyscale
import RHS_filters
import numpy as np
import matplotlib.pyplot as plt

# %% RHS bank
rhs_bank = RHS_filters.filterbank()

# %% Parameters of image
shape = (1024, 1024)  # filtershape in pixels
# visual extent, same convention as pyplot:
visextent = np.array([-0.5, 0.5, -0.5, 0.5]) * (1023 / 32)

# %% Create image coordinate system:
axish = np.linspace(visextent[0], visextent[1], shape[0])
axisv = np.linspace(visextent[2], visextent[3], shape[1])

(x, y) = np.meshgrid(axish, axisv)


# %% Circular Gaussian
def test_circular_Gaussian():
    sigma1 = 2
    sigmas = np.array([1, 1]) * sigma1
    f = multyscale.filters.gaussian2d(x, y, (sigmas[0], sigmas[1]))
    f = f / f.sum()
    f_2 = RHS_filters.d2gauss(
        shape[0], sigmas[0] * 32, shape[1], sigmas[0] * 32, 0
    )