def create_quarter_img(image, padded_name): quarter_img = ds.batch_shift_downscale(image, snippet.quarter_shift()) quarter_name = os.path.join(quarter_dir, "quarter-" + padded_name) util.save_array_image(quarter_img, quarter_name)
def create_random0_img(image, padded_name): random0_img = ds.batch_shift_downscale(image, snippet.random0_shifts()) random0_name = os.path.join(random0_dir, "random0-" + padded_name) util.save_array_image(random0_img, random0_name)
def create_control_img(image, padded_name): control_img = ds.batch_shift_downscale(image, snippet.no_shift()) control_name = os.path.join(control_dir, "control-" + padded_name) util.save_array_image(control_img, control_name)
def create_half_img(image, padded_name): half_img = ds.batch_shift_downscale(image, snippet.half_shift()) half_name = os.path.join(half_dir, "half-" + padded_name) util.save_array_image(half_img, half_name)
def test_uniform_img_shift(self): output = ds.batch_shift_downscale(h.zero_image(8, 8), h.shift_half()) self.assertTrue(numpy.array_equal(output, h.zero_image(2, 2)))
def test_shift_thirds2(self): output = ds.batch_shift_downscale(h.test_img1(), h.shift_thirds()) self.assertTrue(h.close_equal(output, h.downscaled_img1_shift_thirds()))
def test_shift_half2(self): output = ds.batch_shift_downscale(h.test_img1(), h.shift_half()) self.assertTrue( numpy.array_equal(output, h.downscaled_img1_shift_half()))
def test_no_shift2(self): output = ds.batch_shift_downscale(h.test_img1(), (0, 0)) self.assertTrue(numpy.array_equal(output, h.downscaled_img1()))
def test_uniform_img_shift2(self): output = ds.batch_shift_downscale(h.one_image(8, 8), (0, 0.33, 0.66)) self.assertTrue(numpy.array_equal(output, h.one_image(2, 2)))