Type image
Namespace tensorflow.compat.v2.image
Methods
- crop_and_resize
- crop_and_resize_dyn
- draw_bounding_boxes
- draw_bounding_boxes_dyn
- extract_glimpse
- extract_glimpse_dyn
- resize
- resize
- resize_dyn
- sample_distorted_bounding_box
- sample_distorted_bounding_box_dyn
Properties
Public static methods
Tensor crop_and_resize(object image, object boxes, object box_indices, object crop_size, string method, int extrapolation_value, string name)
object crop_and_resize_dyn(object image, object boxes, object box_indices, object crop_size, ImplicitContainer<T> method, ImplicitContainer<T> extrapolation_value, object name)
Tensor draw_bounding_boxes(IGraphNodeBase images, IGraphNodeBase boxes, IGraphNodeBase colors, string name)
object draw_bounding_boxes_dyn(object images, object boxes, object colors, object name)
Draw bounding boxes on a batch of images. Outputs a copy of `images` but draws on top of the pixels zero or more
bounding boxes specified by the locations in `boxes`. The coordinates of the
each bounding box in `boxes` are encoded as `[y_min, x_min, y_max, x_max]`.
The bounding box coordinates are floats in `[0.0, 1.0]` relative to the width
and height of the underlying image. For example, if an image is 100 x 200 pixels (height x width) and the bounding
box is `[0.1, 0.2, 0.5, 0.9]`, the upper-left and bottom-right coordinates of
the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates). Parts of the bounding box may fall outside the image.
Parameters
-
object
images - A `Tensor`. Must be one of the following types: `float32`, `half`. 4-D with shape `[batch, height, width, depth]`. A batch of images.
-
object
boxes - A `Tensor` of type `float32`. 3-D with shape `[batch, num_bounding_boxes, 4]` containing bounding boxes.
-
object
colors -
object
name - A name for the operation (optional).
Returns
-
object
- A `Tensor`. Has the same type as `images`.
Tensor extract_glimpse(IGraphNodeBase input, IGraphNodeBase size, IGraphNodeBase offsets, bool centered, bool normalized, string noise, string name)
object extract_glimpse_dyn(object input, object size, object offsets, ImplicitContainer<T> centered, ImplicitContainer<T> normalized, ImplicitContainer<T> noise, object name)
Extracts a glimpse from the input tensor. Returns a set of windows called glimpses extracted at location
`offsets` from the input tensor. If the windows only partially
overlaps the inputs, the non overlapping areas will be filled with
random noise. The result is a 4-D tensor of shape `[batch_size, glimpse_height,
glimpse_width, channels]`. The channels and batch dimensions are the
same as that of the input tensor. The height and width of the output
windows are specified in the `size` parameter. The argument `normalized` and `centered` controls how the windows are built: * If the coordinates are normalized but not centered, 0.0 and 1.0
correspond to the minimum and maximum of each height and width
dimension.
* If the coordinates are both normalized and centered, they range from
-1.0 to 1.0. The coordinates (-1.0, -1.0) correspond to the upper
left corner, the lower right corner is located at (1.0, 1.0) and the
center is at (0, 0).
* If the coordinates are not normalized they are interpreted as
numbers of pixels.
Parameters
-
object
input - A `Tensor` of type `float32`. A 4-D float tensor of shape `[batch_size, height, width, channels]`.
-
object
size - A `Tensor` of type `int32`. A 1-D tensor of 2 elements containing the size of the glimpses to extract. The glimpse height must be specified first, following by the glimpse width.
-
object
offsets - A `Tensor` of type `float32`. A 2-D integer tensor of shape `[batch_size, 2]` containing the y, x locations of the center of each window.
-
ImplicitContainer<T>
centered - An optional `bool`. Defaults to `True`. indicates if the offset coordinates are centered relative to the image, in which case the (0, 0) offset is relative to the center of the input images. If false, the (0,0) offset corresponds to the upper left corner of the input images.
-
ImplicitContainer<T>
normalized - An optional `bool`. Defaults to `True`. indicates if the offset coordinates are normalized.
-
ImplicitContainer<T>
noise -
object
name - A name for the operation (optional).
Returns
-
object
- A `Tensor` of type `float32`. Usage Example: ```python BATCH_SIZE = 1 IMAGE_HEIGHT = 3 IMAGE_WIDTH = 3 CHANNELS = 1 GLIMPSE_SIZE = (2, 2) image = tf.reshape(tf.range(9, delta=1, dtype=tf.float32), shape=(BATCH_SIZE, IMAGE_HEIGHT, IMAGE_WIDTH, CHANNELS)) output = tf.image.extract_glimpse(image, size=GLIMPSE_SIZE, offsets=[[1, 1]], centered=False, normalized=False) ```
object resize(IGraphNodeBase images, IEnumerable<int> size, ImplicitContainer<T> method, bool preserve_aspect_ratio, bool antialias, string name)
Resize `images` to `size` using the specified `method`. Resized images will be distorted if their original aspect ratio is not
the same as `size`. To avoid distortions see
`tf.compat.v1.image.resize_image_with_pad`. `method` can be one of: * `ResizeMethod.BILINEAR`: [Bilinear interpolation.](
https://en.wikipedia.org/wiki/Bilinear_interpolation)
* `ResizeMethod.NEAREST_NEIGHBOR`: [Nearest neighbor interpolation.](
https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation)
* `ResizeMethod.BICUBIC`: [Bicubic interpolation.](
https://en.wikipedia.org/wiki/Bicubic_interpolation)
* `ResizeMethod.AREA`: Area interpolation. The return value has the same type as `images` if `method` is
`ResizeMethod.NEAREST_NEIGHBOR`. It will also have the same type as `images`
if the size of `images` can be statically determined to be the same as `size`,
because `images` is returned in this case. Otherwise, the return value has
type `float32`.
Parameters
-
IGraphNodeBase
images - 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor of shape `[height, width, channels]`.
-
IEnumerable<int>
size - A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.
-
ImplicitContainer<T>
method - ResizeMethod. Defaults to `ResizeMethod.BILINEAR`.
-
bool
preserve_aspect_ratio - Whether to preserve the aspect ratio. If this is set, then `images` will be resized to a size that fits in `size` while preserving the aspect ratio of the original image. Scales up the image if `size` is bigger than the current size of the `image`. Defaults to False.
-
bool
antialias -
string
name - A name for this operation (optional).
Returns
-
object
- If `images` was 4-D, a 4-D float Tensor of shape `[batch, new_height, new_width, channels]`. If `images` was 3-D, a 3-D float Tensor of shape `[new_height, new_width, channels]`.
object resize(IGraphNodeBase images, IGraphNodeBase size, ImplicitContainer<T> method, bool preserve_aspect_ratio, bool antialias, string name)
Resize `images` to `size` using the specified `method`. Resized images will be distorted if their original aspect ratio is not
the same as `size`. To avoid distortions see
`tf.compat.v1.image.resize_image_with_pad`. `method` can be one of: * `ResizeMethod.BILINEAR`: [Bilinear interpolation.](
https://en.wikipedia.org/wiki/Bilinear_interpolation)
* `ResizeMethod.NEAREST_NEIGHBOR`: [Nearest neighbor interpolation.](
https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation)
* `ResizeMethod.BICUBIC`: [Bicubic interpolation.](
https://en.wikipedia.org/wiki/Bicubic_interpolation)
* `ResizeMethod.AREA`: Area interpolation. The return value has the same type as `images` if `method` is
`ResizeMethod.NEAREST_NEIGHBOR`. It will also have the same type as `images`
if the size of `images` can be statically determined to be the same as `size`,
because `images` is returned in this case. Otherwise, the return value has
type `float32`.
Parameters
-
IGraphNodeBase
images - 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor of shape `[height, width, channels]`.
-
IGraphNodeBase
size - A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.
-
ImplicitContainer<T>
method - ResizeMethod. Defaults to `ResizeMethod.BILINEAR`.
-
bool
preserve_aspect_ratio - Whether to preserve the aspect ratio. If this is set, then `images` will be resized to a size that fits in `size` while preserving the aspect ratio of the original image. Scales up the image if `size` is bigger than the current size of the `image`. Defaults to False.
-
bool
antialias -
string
name - A name for this operation (optional).
Returns
-
object
- If `images` was 4-D, a 4-D float Tensor of shape `[batch, new_height, new_width, channels]`. If `images` was 3-D, a 3-D float Tensor of shape `[new_height, new_width, channels]`.
object resize_dyn(object images, object size, ImplicitContainer<T> method, ImplicitContainer<T> preserve_aspect_ratio, ImplicitContainer<T> antialias, object name)
Resize `images` to `size` using the specified `method`. Resized images will be distorted if their original aspect ratio is not
the same as `size`. To avoid distortions see
`tf.compat.v1.image.resize_image_with_pad`. `method` can be one of: * `ResizeMethod.BILINEAR`: [Bilinear interpolation.](
https://en.wikipedia.org/wiki/Bilinear_interpolation)
* `ResizeMethod.NEAREST_NEIGHBOR`: [Nearest neighbor interpolation.](
https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation)
* `ResizeMethod.BICUBIC`: [Bicubic interpolation.](
https://en.wikipedia.org/wiki/Bicubic_interpolation)
* `ResizeMethod.AREA`: Area interpolation. The return value has the same type as `images` if `method` is
`ResizeMethod.NEAREST_NEIGHBOR`. It will also have the same type as `images`
if the size of `images` can be statically determined to be the same as `size`,
because `images` is returned in this case. Otherwise, the return value has
type `float32`.
Parameters
-
object
images - 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor of shape `[height, width, channels]`.
-
object
size - A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.
-
ImplicitContainer<T>
method - ResizeMethod. Defaults to `ResizeMethod.BILINEAR`.
-
ImplicitContainer<T>
preserve_aspect_ratio - Whether to preserve the aspect ratio. If this is set, then `images` will be resized to a size that fits in `size` while preserving the aspect ratio of the original image. Scales up the image if `size` is bigger than the current size of the `image`. Defaults to False.
-
ImplicitContainer<T>
antialias -
object
name - A name for this operation (optional).
Returns
-
object
- If `images` was 4-D, a 4-D float Tensor of shape `[batch, new_height, new_width, channels]`. If `images` was 3-D, a 3-D float Tensor of shape `[new_height, new_width, channels]`.