Rotate image(s) counter-clockwise by 90 degrees. For example: ```python a=tf.constant([[[1],[2]],[[3],[4]]]) # rotating `a` counter clockwise by 90 degrees a_rot=tf.image.rot90(a,k=1) #rotated `a` print(a_rot) # [[[2],[4]],[[1],[3]]] ``` Args: image: 4-D Tensor of shape `[batch
(image, k=1, name=None)
| 486 | |
| 487 | @tf_export('image.rot90') |
| 488 | def rot90(image, k=1, name=None): |
| 489 | """Rotate image(s) counter-clockwise by 90 degrees. |
| 490 | |
| 491 | |
| 492 | For example: |
| 493 | ```python |
| 494 | a=tf.constant([[[1],[2]],[[3],[4]]]) |
| 495 | # rotating `a` counter clockwise by 90 degrees |
| 496 | a_rot=tf.image.rot90(a,k=1) #rotated `a` |
| 497 | print(a_rot) # [[[2],[4]],[[1],[3]]] |
| 498 | ``` |
| 499 | Args: |
| 500 | image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor |
| 501 | of shape `[height, width, channels]`. |
| 502 | k: A scalar integer. The number of times the image is rotated by 90 degrees. |
| 503 | name: A name for this operation (optional). |
| 504 | |
| 505 | Returns: |
| 506 | A rotated tensor of the same type and shape as `image`. |
| 507 | |
| 508 | Raises: |
| 509 | ValueError: if the shape of `image` not supported. |
| 510 | """ |
| 511 | with ops.name_scope(name, 'rot90', [image, k]) as scope: |
| 512 | image = ops.convert_to_tensor(image, name='image') |
| 513 | image = _AssertAtLeast3DImage(image) |
| 514 | k = ops.convert_to_tensor(k, dtype=dtypes.int32, name='k') |
| 515 | k.get_shape().assert_has_rank(0) |
| 516 | k = math_ops.mod(k, 4) |
| 517 | |
| 518 | shape = image.get_shape() |
| 519 | if shape.ndims == 3 or shape.ndims is None: |
| 520 | return _rot90_3D(image, k, scope) |
| 521 | elif shape.ndims == 4: |
| 522 | return _rot90_4D(image, k, scope) |
| 523 | else: |
| 524 | raise ValueError('\'image\' must have either 3 or 4 dimensions.') |
| 525 | |
| 526 | |
| 527 | def _rot90_3D(image, k, name_scope): |
nothing calls this directly
no test coverage detected