aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/image/python/kernel_tests/image_ops_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/image/python/kernel_tests/image_ops_test.py')
-rw-r--r--tensorflow/contrib/image/python/kernel_tests/image_ops_test.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/tensorflow/contrib/image/python/kernel_tests/image_ops_test.py b/tensorflow/contrib/image/python/kernel_tests/image_ops_test.py
index b8a0706b61..b50177ae56 100644
--- a/tensorflow/contrib/image/python/kernel_tests/image_ops_test.py
+++ b/tensorflow/contrib/image/python/kernel_tests/image_ops_test.py
@@ -36,8 +36,8 @@ _DTYPES = set(
class ImageOpsTest(test_util.TensorFlowTestCase):
def test_zeros(self):
- with self.test_session():
- for dtype in _DTYPES:
+ for dtype in _DTYPES:
+ with self.test_session():
for shape in [(5, 5), (24, 24), (2, 24, 24, 3)]:
for angle in [0, 1, np.pi / 2.0]:
image = array_ops.zeros(shape, dtype)
@@ -46,8 +46,8 @@ class ImageOpsTest(test_util.TensorFlowTestCase):
np.zeros(shape, dtype.as_numpy_dtype()))
def test_rotate_even(self):
- with self.test_session():
- for dtype in _DTYPES:
+ for dtype in _DTYPES:
+ with self.test_session():
image = array_ops.reshape(
math_ops.cast(math_ops.range(36), dtype), (6, 6))
image_rep = array_ops.tile(image[None, :, :, None], [3, 1, 1, 1])
@@ -68,8 +68,8 @@ class ImageOpsTest(test_util.TensorFlowTestCase):
[1, 7, 13, 19, 25, 31], [0, 6, 12, 18, 24, 30]]])
def test_rotate_odd(self):
- with self.test_session():
- for dtype in _DTYPES:
+ for dtype in _DTYPES:
+ with self.test_session():
image = array_ops.reshape(
math_ops.cast(math_ops.range(25), dtype), (5, 5))
image_rep = array_ops.tile(image[None, :, :, None], [3, 1, 1, 1])
@@ -87,9 +87,25 @@ class ImageOpsTest(test_util.TensorFlowTestCase):
[22, 17, 12, 7, 2], [23, 18, 13, 8, 3],
[24, 19, 14, 9, 4]]])
+ def test_translate(self):
+ for dtype in _DTYPES:
+ with self.test_session():
+ image = constant_op.constant(
+ [[1, 0, 1, 0],
+ [0, 1, 0, 1],
+ [1, 0, 1, 0],
+ [0, 1, 0, 1]], dtype=dtype)
+ translation = constant_op.constant([-1, -1], dtypes.float32)
+ image_translated = image_ops.translate(image, translation)
+ self.assertAllEqual(image_translated.eval(),
+ [[1, 0, 1, 0],
+ [0, 1, 0, 0],
+ [1, 0, 1, 0],
+ [0, 0, 0, 0]])
+
def test_compose(self):
- with self.test_session():
- for dtype in _DTYPES:
+ for dtype in _DTYPES:
+ with self.test_session():
image = constant_op.constant(
[[1, 1, 1, 0],
[1, 0, 0, 0],
@@ -246,4 +262,3 @@ class BipartiteMatchTest(test_util.TensorFlowTestCase):
if __name__ == "__main__":
googletest.main()
-