from PIL import Image
import numpy as np
def _rotate_and_crop(image, output_height, output_width, rotation_degree, do_crop):
"""以给定的角,旋转一张图片,设置输出大小。根据需要旋转是否去除黑边。
Args:
image: A `Tensor` representing an image of arbitrary size.
output_height: The height of the image after preprocessing.
output_width: The width of the image after preprocessing.
rotation_degree: The degree of rotation on the image.
do_crop: Do cropping if it is True.
Returns:
A rotated image.
"""
# Rotate the given image with the given rotation degree
if rotation_degree != 0:
image=image.rotate( rotation_degree,Image.NEAREST,expand = False)
# Center crop to ommit black noise on the edges
if do_crop == True:<
pil 随机旋转影像并去除黑边 pytorch
最新推荐文章于 2024-07-27 12:20:46 发布