1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import cv2 import numpy as np
dog = cv2.imread('./dog.jpeg')
if dog is None: print("错误: 找不到图像文件。") exit()
new = cv2.flip(dog, 0) new_2 = cv2.flip(dog, 1)
dog = cv2.resize(dog, None, fx=0.3, fy=0.3, interpolation=cv2.INTER_AREA) new = cv2.resize(new, None, fx=0.3, fy=0.3, interpolation=cv2.INTER_AREA) new_2 = cv2.resize(new_2, None, fx=0.3, fy=0.3, interpolation=cv2.INTER_AREA)
cv2.namedWindow('dog') cv2.moveWindow('dog', 0, 0)
cv2.namedWindow('new') cv2.moveWindow('new', 400, 0)
cv2.namedWindow('new_2') cv2.moveWindow('new_2', 800, 0)
cv2.imshow('dog', dog) cv2.imshow('new', new) cv2.imshow('new_2', new_2)
cv2.waitKey(0) cv2.destroyAllWindows()
|