Wednesday, August 5, 2020

Jul 24, 2020 日誌

學習如何使用opencv。Chapter 3 影像切割及調整尺寸。

Chapter 3 影像切割及調整尺寸

調整影像尺寸( Resize )

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

協同設計

2022 一開始, 將計算機程式與電腦輔助設計實習課程的期末報告導向 Github 倉儲的協同, 倉儲分別在 https://github.com/mdecourse/cp2021_final 與 https://github.com/mdecourse/cad2021_fin...