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

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

 

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和屏幕的对应

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

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

 

相关文章:

  • 2021-07-28
  • 2022-02-24
  • 2021-11-12
  • 2021-05-24
  • 2022-12-23
  • 2021-05-19
  • 2021-06-16
  • 2022-12-23
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2021-06-03
  • 2022-02-06
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
相关资源
相似解决方案