def test_in_memory_distortions(): im, tmpdir = create_colour_temp_image((800, 800), "JPEG") r_d = Operations.Distort(probability=1, grid_width=8, grid_height=8, magnitude=8) tmp_im = r_d.perform_operation([im]) assert tmp_im is not None assert tmp_im[0].size == (800, 800) im_bw, tmpdir_bw = create_greyscale_temp_image((800, 800), "PNG") r_d_bw = Operations.Distort(probability=1, grid_width=8, grid_height=8, magnitude=8) tmp_im_bw = r_d_bw.perform_operation([im_bw]) assert tmp_im_bw is not None assert tmp_im_bw[0].size == (800, 800) assert isinstance(tmp_im_bw[0], Image.Image) shutil.rmtree(tmpdir) shutil.rmtree(tmpdir_bw)
def test_in_memory_distortions(): tmp, tmpdir = create_colour_temp_image((800, 800), "JPEG") r_d = Operations.Distort(probability=1, grid_width=8, grid_height=8, magnitude=8) tmp_im = [] tmp_im.append(Image.open(tmp)) tmp_im = r_d.perform_operation(tmp_im) assert tmp_im is not None assert tmp_im[0].size == (800,800) tmp_bw, tmpdir_bw = create_greyscale_temp_image((800, 800), "PNG") r_d_bw = Operations.Distort(probability=1, grid_width=8, grid_height=8, magnitude=8) tmp_im_bw = [] tmp_im_bw.append(Image.open(tmp_bw)) tmp_im_bw = r_d_bw.perform_operation(tmp_im_bw) assert tmp_im_bw is not None assert tmp_im_bw[0].size == (800,800) assert isinstance(tmp_im_bw[0], Image.Image) tmp.close() tmp_bw.close() shutil.rmtree(tmpdir) shutil.rmtree(tmpdir_bw)
def test_random_brightness_in_memory(): tmp, tmpdir = create_colour_temp_image((800, 800), "JPEG") op = Operations.RandomBrightness(probability=1, min_factor=0.5, max_factor=1.5) tmp_im = [] tmp_im.append(Image.open(tmp)) tmp_im = op.perform_operation(tmp_im) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) tmp_bw, tmpdir_bw = create_greyscale_temp_image((800, 800), "PNG") op = Operations.RandomBrightness(probability=1, min_factor=0.5, max_factor=1.5) tmp_im = [] tmp_im.append(Image.open(tmp)) tmp_im = op.perform_operation(tmp_im) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) tmp.close() tmp_bw.close() shutil.rmtree(tmpdir) shutil.rmtree(tmpdir_bw)
def test_random_brightness_in_memory(): tmp, tmpdir = create_colour_temp_image((800, 800), "JPEG") op = Operations.RandomBrightness(probability=1,min_factor=0.5, max_factor =1.5) tmp_im = [] tmp_im.append(Image.open(tmp)) tmp_im = op.perform_operation(tmp_im) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) tmp_bw, tmpdir_bw = create_greyscale_temp_image((800, 800), "PNG") op = Operations.RandomBrightness(probability=1,min_factor=0.5, max_factor =1.5) tmp_im = [] tmp_im.append(Image.open(tmp)) tmp_im = op.perform_operation(tmp_im) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) tmp.close() tmp_bw.close() shutil.rmtree(tmpdir) shutil.rmtree(tmpdir_bw)
def test_random_brightness_in_memory(): im, tmpdir = create_colour_temp_image((800, 800), "JPEG") op = Operations.RandomBrightness(probability=1, min_factor=0.5, max_factor=1.5) tmp_im = op.perform_operation([im]) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) shutil.rmtree(tmpdir) if os.name == "nt": # not testing bw images return im_bw, tmpdir_bw = create_greyscale_temp_image((800, 800), "PNG") op = Operations.RandomBrightness(probability=1, min_factor=0.5, max_factor=1.5) tmp_im = op.perform_operation([im_bw]) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) shutil.rmtree(tmpdir_bw)
def test_random_contrast_in_memory(): im, tmpdir = create_colour_temp_image((800, 800), "JPEG") op = Operations.RandomContrast(probability=1, min_factor=0.5, max_factor=1.5) tmp_im = op.perform_operation([im]) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) shutil.rmtree(tmpdir) im_bw, tmpdir_bw = create_greyscale_temp_image((800, 800), "PNG") op = Operations.RandomContrast(probability=1, min_factor=0.5, max_factor=1.5) tmp_im = op.perform_operation([im_bw]) assert tmp_im is not None assert isinstance(tmp_im[0], Image.Image) shutil.rmtree(tmpdir_bw)