View source on GitHub |
A preprocessing layer which crops images.
tf.keras.layers.CenterCrop(
height, width, **kwargs
)
This layers crops the central portion of the images to a target size. If an image is smaller than the target size, it will be resized and cropped so as to return the largest possible window in the image that matches the target aspect ratio.
Input pixel values can be of any range (e.g. [0., 1.)
or [0, 255]
) and
of integer or floating point dtype.
By default, the layer will output floats.
For an overview and full list of preprocessing layers, see the preprocessing guide.
Input shape | |
---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Output shape | |
---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
If the input height/width is even and the target height/width is odd (or inversely), the input image is left-padded by 1 pixel.
Args | |
---|---|
height
|
Integer, the height of the output shape. |
width
|
Integer, the width of the output shape. |