Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我想知道它的意思(高度、宽度)=img.shape[:2]_Python_Numpy - Fatal编程技术网

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”对象是什么类型的?