def test_uint8_to_float_and_back():
    img = load_image(TEST_IMAGE_PATH)
    img_float = uint8_to_float(img)
    img_uint8 = float_to_uint8(img_float)
    img_diff = img - img_uint8

    assert img_diff.max() <= 1
def test_collapse_laplacian_pyramid():
    img = load_image(TEST_IMAGE_PATH)
    pyramid = create_laplacian_image_pyramid(img, 5)
    display_image_pyramid(pyramid)
    img_collapsed = collapse_laplacian_pyramid(pyramid)
    display_image(img, "Original")
    display_image(img_collapsed, "Recomposed", wait=True)
    assert (img == img_collapsed).all()
def test_collapse_laplacian_pyramid():
    img = load_image(TEST_IMAGE_PATH)
    pyramid = create_laplacian_image_pyramid(img, 5)
    display_image_pyramid(pyramid)
    img_collapsed = collapse_laplacian_pyramid(pyramid)
    display_image(img, "Original")
    display_image(img_collapsed, "Recomposed", wait=True)
    assert (img == img_collapsed).all()
def test_create_laplacian_image_pyramid():
    pyramid_depth = 3

    img = load_image(TEST_IMAGE_PATH)
    pyramid = create_laplacian_image_pyramid(img, pyramid_depth)
    display_image_pyramid(pyramid)

    means = [np.average(f) for f in pyramid]
    deviations = [np.std(f) for f in pyramid]

    assert len(pyramid) == pyramid_depth
    assert np.std(deviations) > 0.01  # one of the images is just the original sized down photo. there should be significantly more variance in that photo
    assert pyramid[0].shape == img.shape
    assert pyramid[1].shape[0] < pyramid[0].shape[0]
    assert pyramid[2].shape[0] < pyramid[1].shape[0]
def test_create_gaussian_image_pyramid():
    pyramid_depth = 3

    img = load_image(TEST_IMAGE_PATH)
    pyramid = create_gaussian_image_pyramid(img, pyramid_depth)
    display_image_pyramid(pyramid)

    means = [np.average(f) for f in pyramid]
    deviations = [np.std(f) for f in pyramid]

    assert len(pyramid) == pyramid_depth
    assert np.std(means) < 1
    assert np.std(deviations) < 1
    assert pyramid[0].shape == img.shape
    assert pyramid[1].shape[0] < pyramid[0].shape[0]
    assert pyramid[2].shape[0] < pyramid[1].shape[0]
def test_create_gaussian_image_pyramid():
    pyramid_depth = 3

    img = load_image(TEST_IMAGE_PATH)
    pyramid = create_gaussian_image_pyramid(img, pyramid_depth)
    display_image_pyramid(pyramid)

    means = [np.average(f) for f in pyramid]
    deviations = [np.std(f) for f in pyramid]

    assert len(pyramid) == pyramid_depth
    assert np.std(means) < 1
    assert np.std(deviations) < 1
    assert pyramid[0].shape == img.shape
    assert pyramid[1].shape[0] < pyramid[0].shape[0]
    assert pyramid[2].shape[0] < pyramid[1].shape[0]
def test_create_laplacian_image_pyramid():
    pyramid_depth = 3

    img = load_image(TEST_IMAGE_PATH)
    pyramid = create_laplacian_image_pyramid(img, pyramid_depth)
    display_image_pyramid(pyramid)

    means = [np.average(f) for f in pyramid]
    deviations = [np.std(f) for f in pyramid]

    assert len(pyramid) == pyramid_depth
    assert np.std(
        deviations
    ) > 0.01  # one of the images is just the original sized down photo. there should be significantly more variance in that photo
    assert pyramid[0].shape == img.shape
    assert pyramid[1].shape[0] < pyramid[0].shape[0]
    assert pyramid[2].shape[0] < pyramid[1].shape[0]