def test_sample_patch_small_patch_returns_downscaled_image(self): image_np = np.reshape(np.arange(3 * 3), [3, 3, 1]) image = tf.constant(image_np, dtype=tf.float32) image_patch = data_provider.sample_patch( image, patch_height=2, patch_width=2, colors=1) with self.cached_session() as sess: image_patch_np = sess.run(image_patch) expected_np = np.asarray([[[0.], [1.5]], [[4.5], [6.]]]) self.assertAllClose(image_patch_np, expected_np, 1.0e-6)
def test_sample_patch_large_patch_returns_upscaled_image(self): image_np = np.reshape(np.arange(2 * 2), [2, 2, 1]) image = tf.constant(image_np, dtype=tf.float32) image_patch = data_provider.sample_patch( image, patch_height=3, patch_width=3, colors=1) with self.cached_session() as sess: image_patch_np = sess.run(image_patch) expected_np = np.asarray([[[0.], [0.66666669], [1.]], [[1.33333337], [2.], [2.33333349]], [[2.], [2.66666675], [3.]]]) self.assertAllClose(image_patch_np, expected_np, 1.0e-6)