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
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.
Usage Example:
x = [[[[0.0],
[1.0],
[2.0]],
[[3.0],
[4.0],
[5.0]],
[[6.0],
[7.0],
[8.0]]]]
tf.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([[[[4.],
[5.]],
[[7.],
[8.]]]], dtype=float32)>
Returns | |
---|---|
A Tensor of type float32 .
|