Пример #1
0
 def test_compose(self):
     for dtype in _DTYPES:
         with self.test_session():
             image = constant_op.constant(
                 [[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 1, 0], [0, 0, 0, 0]],
                 dtype=dtype)
             # Rotate counter-clockwise by pi / 2.
             rotation = image_ops.angles_to_projective_transforms(
                 np.pi / 2, 4, 4)
             # Translate right by 1 (the transformation matrix is always inverted,
             # hence the -1).
             translation = constant_op.constant([1, 0, -1, 0, 1, 0, 0, 0],
                                                dtype=dtypes.float32)
             composed = image_ops.compose_transforms(rotation, translation)
             image_transformed = image_ops.transform(image, composed)
             self.assertAllEqual(
                 image_transformed.eval(),
                 [[0, 0, 0, 0], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 1, 1]])
Пример #2
0
 def test_compose(self):
   for dtype in _DTYPES:
     with self.cached_session():
       image = constant_op.constant(
           [[1, 1, 1, 0],
            [1, 0, 0, 0],
            [1, 1, 1, 0],
            [0, 0, 0, 0]], dtype=dtype)
       # Rotate counter-clockwise by pi / 2.
       rotation = image_ops.angles_to_projective_transforms(np.pi / 2, 4, 4)
       # Translate right by 1 (the transformation matrix is always inverted,
       # hence the -1).
       translation = constant_op.constant([1, 0, -1,
                                           0, 1, 0,
                                           0, 0],
                                          dtype=dtypes.float32)
       composed = image_ops.compose_transforms(rotation, translation)
       image_transformed = image_ops.transform(image, composed)
       self.assertAllEqual(image_transformed.eval(),
                           [[0, 0, 0, 0],
                            [0, 1, 0, 1],
                            [0, 1, 0, 1],
                            [0, 1, 1, 1]])