Python 我想知道它的意思(高度、宽度)=img.shape[:2]
我不知道那是什么意思Python 我想知道它的意思(高度、宽度)=img.shape[:2],python,numpy,Python,Numpy,我不知道那是什么意思 def rotate(img,angle,rotPoint=None): (height,width)=img.shape[:2] if rotPoint is None: rotPoint= (width//2,height//2) rotMate=cv.getRotationMatrix2D(rotPoint,angle,1.0) dimensions=(width,height) return cv.warpAf
def rotate(img,angle,rotPoint=None):
(height,width)=img.shape[:2]
if rotPoint is None:
rotPoint= (width//2,height//2)
rotMate=cv.getRotationMatrix2D(rotPoint,angle,1.0)
dimensions=(width,height)
return cv.warpAffine(img,rotMate,dimensions)
我的意思是:
def rotate(img,angle,rotPoint=None):
(height,width)=img.shape[:2]
我想要一些解释显然
img
对象的shape
属性是一个包含一些图像数据的列表,其中前两个元素在这里被复制到变量height
和width这取决于“img”对象的类型。你在用什么?我想是吧
然后,对象的形状包含一个元组(行、列、通道)
(高度,宽度)=img。shape[:2]
是元组解包的一个示例,使用它可以从shape元组中提取行
和列
值。您应该告诉我们有关导入的信息,“img”对象是什么类型的?