學習如何使用opencv。Chapter 3 影像切割及調整尺寸。
Chapter 3 影像切割及調整尺寸
調整影像尺寸( Resize )
Opencv 的 XY 軸座標的原點是在左上角越往右下 X 和 Y 的值越大。
影像切割
import cv2
img = cv2.imread("lena.png")
print(img.shape)#show the image size(width,height,channel)
imgResize = cv2.resize(img,(1024,1024)) #resize the lean.png:(image,(Y_size,X_size))
print(imgResize.shape)
imgCropped = img[200:388,220:355] #cut the image [y1:y2,x1:x2],the origin of image at upper left corner.
cv2.imshow("Image",img)
cv2.imshow("Image Resize",imgResize)
cv2.imshow("Cropped Image",imgCropped)
cv2.waitKey(0)
No comments:
Post a Comment