Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- JavaScript
- Data Structure
- 알고리듬
- Priority Queue
- Bruth Force
- GitHub
- 구현
- Back tracking
- Algorithm
- SWEA
- DFS
- Vue.js
- gpdb
- Linked list
- SQL
- CSV
- 시뮬레이션
- 코테
- BFS
- hash table
- boj
- 코딩테스트
- aws
- spring boot
- programmers
- Python
- django
- Trie
- 알고리즘
- 모의SW역량테스트
Archives
- Today
- Total
hotamul의 개발 이야기
[Python] OpenCV로 image size 조절하기 본문
Interpolation Methods for resizing
cv2.INTER_AREA
: 주로 이미지 크기를 줄이는데 사용한다.cv2.INTER_CUBIC
: 속도는 느리지만 Interpolation 성능이 좋다.cv2.INTER_LINEAR
: 주로 이미지 크기를 늘리는데 사용하고 OpenCV의 default Interpolation method이다.
참고: OpenCV - InterpolationFlags
Shrink & Enlarge Image
$ pip install opencv-python-headless numpy
import numpy as np
import cv2
# loading image
img = cv2.imread('./testimg.jpg')
# shrinking image
# width = columns , height = rows
img_shrink = cv2.resize(img, dsize=(320,240), interpolation=cv2.INTER_AREA)
# enlarge
# cv2.INTER_CUBIC, cv2.INTER_LINEAR
img_zoom = cv2.resize(img, dsize=(1280,960), interpolation=cv2.INTER_CUBIC)
# Check size
print(img.shape, img_shrink.shape, img_zoom.shape)
((480, 640, 3), (240, 320, 3), (960, 1280, 3))
# Show image
cv2.imshow('original',img)
cv2.imshow('Shink',img_shrink)
cv2.imshow('Zoom',img_zoom)
cv2.waitKey(0)
cv2.destroyAllWindows()
'Dev. > Python' 카테고리의 다른 글
진짜 이상한 Python의 del (0) | 2023.12.11 |
---|---|
[Python] OpenCV Face Detection (0) | 2023.01.01 |
[Python] image 파일 numpy.ndarray로 불러오기 (0) | 2023.01.01 |
[Data][Python] Pandas + Numpy example (0) | 2022.01.10 |
[Data][Python] Pandas example (0) | 2022.01.10 |
Comments