python+opencv图像长宽xy和屏幕的对应

左上角是原点,往下是x/height。往右是y/width。

python+opencv图像长宽xy和屏幕的对应_第1张图片

 

import cv2
import numpy as np

img = cv2.imread('Parthenon.jpg')

h,w,l = np.shape(img)

(h1, w1) = img.shape[:2] #tuple

print(h,w,l)
print(h1,w1)

cv2.imshow('Parthenon',img)


img1 = np.copy(img)

for x in range(200):
    img1[x,:] = 0
    
cv2.imshow('Parthenon1',img1)

img2 = np.copy(img)

for y in range(200):
    img2[:,y] = 0
    
cv2.imshow('Parthenon2',img2)

输出:

(498, 800, 3)
(498, 800)

python+opencv图像长宽xy和屏幕的对应_第2张图片

python+opencv图像长宽xy和屏幕的对应_第3张图片

python+opencv图像长宽xy和屏幕的对应_第4张图片

 

你可能感兴趣的:(空间艺术Raumkunst)