|TensorFlow 1 version||View source on GitHub|
Extracts a glimpse from the input tensor.
tf.image.extract_glimpse( input, size, offsets, centered=True, normalized=True, noise='uniform', 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
The result is a 4-D tensor of shape
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
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.
float32. A 4-D float tensor of shape
[batch_size, height, width, channels].
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.
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.
noise: An optional
string. Defaults to
uniform. indicates if the noise should be
gaussian(gaussian distribution), or
name: A name for the operation (optional).
Tensor of type
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) ```