tf.image.crop_to_bounding_box
tf.image.crop_to_bounding_box
tf.image.crop_to_bounding_box
crop_to_bounding_box( image, offset_height, offset_width, target_height, target_width )
Defined in tensorflow/python/ops/image_ops_impl.py
.
See the guide: Images > Cropping
Crops an image to a specified bounding box.
This op cuts a rectangular part out of image
. The top-left corner of the returned image is at offset_height, offset_width
in image
, and its lower-right corner is at offset_height + target_height, offset_width + target_width
.
Args:
-
image
: 4-D Tensor of shape[batch, height, width, channels]
or 3-D Tensor of shape[height, width, channels]
. -
offset_height
: Vertical coordinate of the top-left corner of the result in the input. -
offset_width
: Horizontal coordinate of the top-left corner of the result in the input. -
target_height
: Height of the result. -
target_width
: Width of the result.
Returns:
If image
was 4-D, a 4-D float Tensor of shape [batch, target_height, target_width, channels]
If image
was 3-D, a 3-D float Tensor of shape [target_height, target_width, channels]
Raises:
-
ValueError
: If the shape ofimage
is incompatible with theoffset_*
ortarget_*
arguments, or eitheroffset_height
oroffset_width
is negative, or eithertarget_height
ortarget_width
is not positive.
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/image/crop_to_bounding_box