def test_hue(): img = image_loader(os.path.join(TEST_DATA_PATH, "images", "flower2.jpg")) transform = Hue() res_img = transform(img) assert np.array(res_img)[100][0] == 39
def test_compose(): img = image_loader(os.path.join(TEST_DATA_PATH, "images", "flower2.jpg")) transforms = ComposeTransforms([Saturation(), np.mean]) res_compose = transforms(img) transform_sat_only = Saturation() res_img = transform_sat_only(img) # compute average brightness res = np.mean(res_img) assert res == res_compose
def test_simple_blur(image_files): expected_results = [3754.4, 1392.5, 13544.2, ] transform = SimpleBlur() for idx, eachimg in enumerate(image_files): img = image_loader(eachimg) res = transform(img) # compute average brightness assert pytest.approx(res, 0.1) == expected_results[idx]
def test_Brightness(): img = image_loader(os.path.join(TEST_DATA_PATH, "images", "flower2.jpg")) transform = Brightness() res_img = transform(img) # compute average brightness res = np.mean(res_img) assert pytest.approx(res, 0.1) == 117.1 res_img = transform(np.array(img)) # compute average brightness res = np.mean(res_img) assert pytest.approx(res, 0.1) == 117.1
def test_simple_blur(image_files): expected_results = [ 3754.4, 449.4, 700.7, 1392.5, 382.6, 239.1, 300.9, 851.9, 594.9, 729.9, 895.8, 13544.2, ] transform = SimpleBlur() for idx, eachimg in enumerate(image_files): img = image_loader(eachimg) res = transform(img) assert pytest.approx(res, 0.1) == expected_results[ idx], f"index:{idx} res:{res} expected: {expected_results[idx]}"