[ Python OpenCV ] 파이썬 오픈씨브이 이미지 사이즈 변경 - cv2.resize
# cv2.resize(이미지, 절대 크기, 상대크기, 보간법)
1. 원본 이미지
import cv2 as cv
# 이미지 가져오기
image = cv.imread('/home/heojungwook/VSCode
/cat.jpeg')
# 이미지 보기
cv.imshow('Cat', image)
2. 입력 크기 변경
# 사이즈 변경
reSizeImage = cv.resize(image, dsize=(320, 240))
# 이미지 보기
cv.imshow('reSizeCat', reSizeImage)
3. 절대 크기 변경
# 절대 크기 변경
RatioImage = cv.resize(image, dsize=(0, 0),
fx=0.2, fy=0.2)
# 이미지 보기
cv.imshow('RatioImage', RatioImage)
4. 보간법 종류
INTER_AREA = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_AREA)
cv.imshow('INTER_AREA', INTER_AREA)
INTER_BITS = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_BITS)
cv.imshow('INTER_BITS', INTER_BITS)
INTER_BITS2 = cv.resize(image, dsize=(320, 240),
interpolation=cv.INTER_BITS2)
cv.imshow('INTER_BITS2', INTER_BITS2)
INTER_CUBIC = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_CUBIC)
cv.imshow('INTER_CUBIC', INTER_CUBIC)
INTER_LANCZOS4 = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_LANCZOS4)
cv.imshow('INTER_LANCZOS4', INTER_LANCZOS4)
INTER_LINEAR = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_LINEAR)
cv.imshow('INTER_LINEAR', INTER_LINEAR)
INTER_LINEAR_EXACT = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_LINEAR_EXACT)
cv.imshow('INTER_LINEAR_EXACT', INTER_LINEAR_EXACT)
INTER_NEAREST = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_NEAREST)
cv.imshow('INTER_NEAREST', INTER_NEAREST)
INTER_NEAREST_EXACT = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTER_NEAREST_EXACT)
cv.imshow('INTER_NEAREST_EXACT', INTER_NEAREST_EXACT)
INTERSECT_FULL = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTERSECT_FULL)
cv.imshow('INTERSECT_FULL', INTERSECT_FULL)
INTERSECT_NONE = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTERSECT_NONE)
cv.imshow('INTERSECT_NONE', INTERSECT_NONE)
INTERSECT_PARTIAL = cv.resize(image,
dsize=(320, 240),
interpolation=cv.INTERSECT_PARTIAL)
cv.imshow('INTERSECT_PARTIAL', INTERSECT_PARTIAL)
==========
댓글
댓글 쓰기