Exemple #1
0
def test_gauss():
    w = gauss(3, std=1e-3)
    w /= w.max()

    expected = np.zeros((3, 3))
    expected[1, 1] = 1

    assert_array_equal(w, expected)
Exemple #2
0

if __name__ == "__main__":
    scale = 3

    theta = 5 / 180. * np.pi
    C = np.cos(theta)
    S = np.sin(theta)
    tx, ty = 0, 0

    A = bilinear(
        HR.shape[0], HR.shape[1],
        [np.array([[C / scale, -S, tx], [S, C / scale, ty], [0, 0, 1.]])],
        HR.shape[0] / scale, HR.shape[1] / scale)

    C = convolve(HR.shape[0], HR.shape[1], gauss(5, std=1))

    import matplotlib.pyplot as plt
    plt.spy((A * C).todense())

    plt.figure()
    fwd = (A * C * HR.flat)
    rev = C.T * A.T * fwd

    plt.subplot(1, 3, 1)
    plt.imshow(HR, cmap=plt.cm.gray, interpolation='nearest')

    plt.subplot(1, 3, 2)
    plt.imshow(fwd.reshape(np.array(HR.shape) / scale),
               interpolation='nearest',
               cmap=plt.cm.gray)
Exemple #3
0
if __name__ == "__main__":
    scale = 3

    theta = 5 / 180. * np.pi
    C = np.cos(theta)
    S = np.sin(theta)
    tx, ty = 0, 0

    A = bilinear(HR.shape[0], HR.shape[1],
                 [np.array([[C/scale, -S,        tx],
                            [S,        C/scale,  ty],
                            [0,        0,        1.]])],
                  HR.shape[0] / scale, HR.shape[1] / scale)


    C = convolve(HR.shape[0], HR.shape[1], gauss(5, std=1))

    import matplotlib.pyplot as plt
    plt.spy((A * C).todense())

    plt.figure()
    fwd = (A * C * HR.flat)
    rev = C.T * A.T * fwd

    plt.subplot(1, 3, 1)
    plt.imshow(HR, cmap=plt.cm.gray, interpolation='nearest')

    plt.subplot(1, 3, 2)
    plt.imshow(fwd.reshape(np.array(HR.shape) / scale),
               interpolation='nearest', cmap=plt.cm.gray)
    plt.subplot(1, 3, 3)