Function Differences with tf.image.central_crop
tf.image.central_crop
tf.image.central_crop(
image,
central_fraction
)
For more information, see tf.image.central_crop.
mindspore.dataset.vision.c_transforms.CenterCrop
class mindspore.dataset.vision.c_transforms.CenterCrop(
size
)
For more information, see mindspore.dataset.vision.c_transforms.CenterCrop.
Differences
TensorFlow: Crop the central region of the image with desired crop ratio.
MindSpore: Crop the central region of the image with desired output size.
Code Example
# The following implements CenterCrop with MindSpore.
import numpy as np
import mindspore.dataset as ds
image = np.random.random((28, 28, 3))
result = ds.vision.c_transforms.CenterCrop((14, 14))(image)
print(result.shape)
# (14, 14, 3)
# The following implements central_crop with TensorFlow.
import tensorflow as tf
image = tf.random.normal((28, 28, 3))
result = tf.image.central_crop(image, 0.5)
print(result.shape)
# (14, 14, 3)