Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy
- # 加载图像并显示
- if __name__ == '__main__':
- # Read image
- image = cv2.imread( "/Users/laichian/Desktop/Computer_Vision/homework-3-MattLai-master/PKLot/parking1b/sunny/2013-02-22/2013-02-22_06_05_00.jpg",0)
- # Select ROI
- #r = cv2.selectROI(image)
- # Crop image
- #imCrop = image[int(r[1]):int(r[1] + r[3]), int(r[0]):int(r[0] + r[2])]
- # Display cropped image
- #cv2.imshow("Image", imCrop)
- #cv2.waitKey(0)
- #rect: (453,369), (543,386), (573,334), (446,304)
- #rect: (278,90), (349,97), (364,65), (287,51)
- #x="502" y="348" w="61" h="130"
- cv2.rectangle(image, (453, 369), (573, 334), 3) #12
- cv2.imshow("Canvas", image) #13
- cv2.waitKey(0)
- #crop_img = image[369:334,453:573] # Crop from x, y, w, h -> 502, 348, 61, 130
- # NOTE: its img[y: y + h, x: x + w] and *not* img[x: x + w, y: y + h]
- #cv2.imshow("cropped", crop_img)
- #cv2.waitKey(0)
- #mouth = image[85:250, 85:220]
- #看上去,numpy的数组切片只需要提供高度区间和宽度区间即可。事实上也确实是这样。
- #上面的语句表示提取矩形区域(左上角坐标(85,85),右下角坐标(220,250))的图像。
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement