Two deformation methods of tensorflow image

There is also the padding, which can prevent the image from deforming, but the result is not good, because there are too many irrelevant factors on the pad, so we don’t use this.
1. For labels, fill with the nearest neighbor’s value:

tf.image.resize_nearest_neighbor(
        tf.expand_dims(label, 0),
        new_dim,
        align_corners=True)

2. Apply to images, using bilinear interpolation

tf.image.resize_bilinear(
      tf.expand_dims(image, 0),
      new_dim,
      align_corners=True)

Because both of the above methods require four dimensions, expand_dim
Capital water. But I’m actually writing code for myself for easy review, funny.

Read More: