tf.compat.v1.image.extract_glimpse

View source on GitHub

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:

Args:

Returns:

A Tensor of type float32.

Usage Example:

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)
 ```