Extracts a glimpse from the input tensor.
tf.compat.v1.image.extract_glimpse( input, size, offsets, centered=True, normalized=True, uniform_noise=True, name=None )
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:
x = [[[[0.0], [1.0], [2.0]], [[3.0], [4.0], [5.0]], [[6.0], [7.0], [8.0]]]] tf.compat.v1.image.extract_glimpse(x, size=(2, 2), offsets=[[1, 1]], centered=False, normalized=False) <tf.Tensor: shape=(1, 2, 2, 1), dtype=float32, numpy= array([[[[0.], [1.]], [[3.], [4.]]]], dtype=float32)>
Args | |
---|---|
input | A Tensor of type float32 . A 4-D float tensor of shape [batch_size, height, width, channels] . |
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. |
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. |
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. |
normalized | An optional bool . Defaults to True . indicates if the offset coordinates are normalized. |
uniform_noise | An optional bool . Defaults to True . indicates if the noise should be generated using a uniform distribution or a Gaussian distribution. |
name | A name for the operation (optional). |
Returns | |
---|---|
A Tensor of type float32 . |
© 2020 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/versions/r2.4/api_docs/python/tf/compat/v1/image/extract_glimpse