Rotate image counter-clockwise by 90 degrees `k` times. Args: image: 3-D Tensor of shape `[height, width, channels]`. k: A scalar integer. The number of times the image is rotated by 90 degrees. name_scope: A valid TensorFlow name scope. Returns: A 3-D tensor of the same type a
(image, k, name_scope)
| 525 | |
| 526 | |
| 527 | def _rot90_3D(image, k, name_scope): |
| 528 | """Rotate image counter-clockwise by 90 degrees `k` times. |
| 529 | |
| 530 | Args: |
| 531 | image: 3-D Tensor of shape `[height, width, channels]`. |
| 532 | k: A scalar integer. The number of times the image is rotated by 90 degrees. |
| 533 | name_scope: A valid TensorFlow name scope. |
| 534 | |
| 535 | Returns: |
| 536 | A 3-D tensor of the same type and shape as `image`. |
| 537 | |
| 538 | """ |
| 539 | |
| 540 | def _rot90(): |
| 541 | return array_ops.transpose(array_ops.reverse_v2(image, [1]), [1, 0, 2]) |
| 542 | |
| 543 | def _rot180(): |
| 544 | return array_ops.reverse_v2(image, [0, 1]) |
| 545 | |
| 546 | def _rot270(): |
| 547 | return array_ops.reverse_v2(array_ops.transpose(image, [1, 0, 2]), [1]) |
| 548 | |
| 549 | cases = [(math_ops.equal(k, 1), _rot90), (math_ops.equal(k, 2), _rot180), |
| 550 | (math_ops.equal(k, 3), _rot270)] |
| 551 | |
| 552 | result = control_flow_ops.case( |
| 553 | cases, default=lambda: image, exclusive=True, name=name_scope) |
| 554 | result.set_shape([None, None, image.get_shape()[2]]) |
| 555 | return result |
| 556 | |
| 557 | |
| 558 | def _rot90_4D(images, k, name_scope): |