Flip an image either horizontally or vertically. Outputs the contents of `image` flipped along the dimension `flip_index`. See also `reverse()`. Args: image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor of shape `[height, width, channels]`. flip_index:
(image, flip_index, scope_name)
| 454 | |
| 455 | |
| 456 | def _flip(image, flip_index, scope_name): |
| 457 | """Flip an image either horizontally or vertically. |
| 458 | |
| 459 | Outputs the contents of `image` flipped along the dimension `flip_index`. |
| 460 | |
| 461 | See also `reverse()`. |
| 462 | |
| 463 | Args: |
| 464 | image: 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor |
| 465 | of shape `[height, width, channels]`. |
| 466 | flip_index: 0 For vertical, 1 for horizontal. |
| 467 | scope_name: string, scope name. |
| 468 | |
| 469 | Returns: |
| 470 | A `Tensor` of the same type and shape as `image`. |
| 471 | |
| 472 | Raises: |
| 473 | ValueError: if the shape of `image` not supported. |
| 474 | """ |
| 475 | with ops.name_scope(None, scope_name, [image]): |
| 476 | image = ops.convert_to_tensor(image, name='image') |
| 477 | image = _AssertAtLeast3DImage(image) |
| 478 | shape = image.get_shape() |
| 479 | if shape.ndims == 3 or shape.ndims is None: |
| 480 | return fix_image_flip_shape(image, array_ops.reverse(image, [flip_index])) |
| 481 | elif shape.ndims == 4: |
| 482 | return array_ops.reverse(image, [flip_index + 1]) |
| 483 | else: |
| 484 | raise ValueError('\'image\' must have either 3 or 4 dimensions.') |
| 485 | |
| 486 | |
| 487 | @tf_export('image.rot90') |
no test coverage detected