def test_should_not_fail_using_fixed_alpha_enabled_and_float32_dtype(self): image_data_3_with_multiple_alpha = add_alpha_channel(IMAGE_DATA_3, 0.5) image_data_3_with_multiple_alpha[0, 0, 3] = 123 combine_images([ IMAGE_DATA_1.astype(np.uint8), add_alpha_channel(IMAGE_DATA_2, 0.5).astype(np.uint8), image_data_3_with_multiple_alpha.astype(np.float32) ], fixed_alpha_enabled=True)
def test_should_overlay_multiple_images_with_alpha_on_image_without_alpha(self): np.testing.assert_allclose(combine_images([ IMAGE_DATA_1, add_alpha_channel(IMAGE_DATA_2, 0.5), add_alpha_channel(IMAGE_DATA_3, 0.5) ], fixed_alpha_enabled=True), ( (IMAGE_DATA_1 * 0.5 + IMAGE_DATA_2 * 0.5) * 0.5 + IMAGE_DATA_3 * 0.5 ), rtol=0.1)
def do_filter(self, image_array: ImageArray) -> ImageArray: assert isinstance(image_array, LazyImageList) lazy_images = image_array.images images = list(reversed([ lazy_image.image for lazy_image in reversed(lazy_images) ])) with self.context.timer.enter_step(f'{self.filter_id}.combine'): return combine_images(images)
def test_should_overlay_image_with_alpha_on_image_without_alpha(self): np.testing.assert_allclose(combine_images([ IMAGE_DATA_1, add_alpha_channel(IMAGE_DATA_2, 0.5) ]), IMAGE_DATA_1 * 0.5 + IMAGE_DATA_2 * 0.5, rtol=0.1)
def test_should_return_last_image_if_without_alpha(self): np.testing.assert_allclose(combine_images([ IMAGE_DATA_1, IMAGE_DATA_2, IMAGE_DATA_3 ]), IMAGE_DATA_3)
def test_should_return_passed_in_image_with_alpha_if_received_single_image(self): image = add_alpha_channel(IMAGE_DATA_1, 0.5) np.testing.assert_allclose(combine_images([ image ]), image)
def test_should_return_passed_in_image_if_received_single_image(self): np.testing.assert_allclose(combine_images([IMAGE_DATA_1]), IMAGE_DATA_1)
def test_should_return_raise_exception_for_empty_list(self): with pytest.raises(AssertionError): combine_images([])