tf.keras.layers.CenterCrop

A preprocessing layer which crops images.

Inherits From: Layer, Module

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 interger or floating point dtype. By default, the layer will output floats.

For an overview and full list of preprocessing layers, see the preprocessing guide.

3D unbatched) or 4D (batched) tensor with shape

(..., height, width, channels), in "channels_last" format.

3D unbatched) or 4D (batched) tensor with shape

(..., target_height, target_width, channels).

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.

height Integer, the height of the output shape.
width Integer, the width of the output shape.