resize 関数の利用法の一つは、第2引数(dsize)にサイズのタプルを与えることである。
以下の例では、高さ(img.shape[0])と幅(img.shape[1])をそれぞれ半分にしている。
import cv2 img = cv2.imread(画像へのパス) if img is None: print("File is not Found.") img2 = cv2.resize(img, (int(img.shape[1]/2), int(img.shape[0]/2))) cv2.imshow("resize", img2) cv2.waitKey(0) cv2.destroyAllWindows()
オリジナル版 | 縮小版 |
---|---|
![]() |
![]() |
以下の例では、元画像の 1.5 倍の画像を表示している。
img2 = cv2.resize(img, None, fx=1.5, fy=1.5) cv2.imshow("resize", img2) cv2.waitKey(0) cv2.destroyAllWindows()
オリジナル版 | 拡大版 |
---|---|
![]() |
![]() |
0 件のコメント:
コメントを投稿