MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _rot90_4D

Function _rot90_4D

tensorflow/python/ops/image_ops_impl.py:558–587  ·  view source on GitHub ↗

Rotate batch of images counter-clockwise by 90 degrees `k` times. Args: images: 4-D Tensor of shape `[height, width, channels]`. k: A scalar integer. The number of times the images are rotated by 90 degrees. name_scope: A valid TensorFlow name scope. Returns: A 4-D `Tenso

(images, k, name_scope)

Source from the content-addressed store, hash-verified

556
557
558def _rot90_4D(images, k, name_scope):
559 """Rotate batch of images counter-clockwise by 90 degrees `k` times.
560
561 Args:
562 images: 4-D Tensor of shape `[height, width, channels]`.
563 k: A scalar integer. The number of times the images are rotated by 90
564 degrees.
565 name_scope: A valid TensorFlow name scope.
566
567 Returns:
568 A 4-D `Tensor` of the same type and shape as `images`.
569 """
570
571 def _rot90():
572 return array_ops.transpose(array_ops.reverse_v2(images, [2]), [0, 2, 1, 3])
573
574 def _rot180():
575 return array_ops.reverse_v2(images, [1, 2])
576
577 def _rot270():
578 return array_ops.reverse_v2(array_ops.transpose(images, [0, 2, 1, 3]), [2])
579
580 cases = [(math_ops.equal(k, 1), _rot90), (math_ops.equal(k, 2), _rot180),
581 (math_ops.equal(k, 3), _rot270)]
582
583 result = control_flow_ops.case(
584 cases, default=lambda: images, exclusive=True, name=name_scope)
585 shape = result.get_shape()
586 result.set_shape([shape[0], None, None, shape[3]])
587 return result
588
589
590@tf_export('image.transpose', v1=['image.transpose', 'image.transpose_image'])

Callers 1

rot90Function · 0.85

Calls 4

equalMethod · 0.80
caseMethod · 0.80
get_shapeMethod · 0.45
set_shapeMethod · 0.45

Tested by

no test coverage detected