我正在按以下方式旋转图片:
# Read in image
img = cv2.imread("pic.jpg")
height, width, _ = img.shape
print("height ", height)
print("width ", width)
# Rotate image by 90 degrees
augmentation = iaa.Affine(rotate=90)
img_aug = augmentation(image=img)
height, width, _ = img_aug.shape
print("Height after rotation ", height)
print("Width after rotation ", width
> height 1080
> width 1920
> Height after rotation 1080
> Width after rotation 1920
为什么图像的形状没有改变
图像增强不会改变图像的实际或物理
shape
。把原始的shape
想象成一个window
,从那里你可以看到图像或外部世界。在这里,所有的转换,即rotations
、stretchings
、translation
或通常的任何homography
或非线性warps
都应用于窗口外的世界。在我的类比中,从你看图像的那个窗口,无论外面的世界如何变化,也就是图像如何变化,都保持不变现在,它显然可以将原始视图中不存在的其他区域引入到增强视图中。最常见的情况是,新引入的像素将是黑色的,或者它可能取决于应用了什么类型的
padding
简言之,扩充操作不像矩阵
transpose
,实际形状可能会发生变化让我们看看图片:
相关问题 更多 >
编程相关推荐