cv2.resize(): 크기 조절 함수
2023. 3. 28. 23:02ㆍOpenCV
cv2.resize(src, dstSize, fx, fy, interpolation): 크기 변환
- src: 입력 이미지
- dstSize: 절대 크기
- fx, fy: 상대 크기
- interpolation: 보간법
예시
image = cv2.imread("fruits.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
plt.figure(figsize=(20, 20))
plt.subplot(2, 2, 1)
plt.title("Original")
plt.imshow(image)
# 원래 크기의 3/4로 resize
image_scaled = cv2.resize(image, None, fx=0.75, fy=0.75)
plt.subplot(2, 2, 2)
plt.title("Scaling - Linear Interpolation")
plt.imshow(image_scaled)
# 원래 크기의 2배로 resize
img_scaled = cv2.resize(image, None, fx=2, fy=2, interpolation = cv2.INTER_CUBIC)
plt.subplot(2, 2, 3)
plt.title("Scaling - Cubic Interpolation")
plt.imshow(img_scaled)
# 정확한 치수를 설정하여 크기를 조정
img_scaled = cv2.resize(image, (900, 400), interpolation = cv2.INTER_AREA)
plt.subplot(2, 2, 4)
plt.title("Scaling - Skewed Size")
plt.imshow(img_scaled)
'OpenCV' 카테고리의 다른 글
Cropping: 화면 자르기 (0) | 2023.03.28 |
---|---|
cv2.pyrDown(), pyrUp(): 이미지 피라미드 (0) | 2023.03.28 |
투시 변환 함수: cv2.getPerspectiveTransform, cv2.warpPerspective (0) | 2023.03.27 |
cv2.Sobel(): 소벨 필터를 이용한 미분 함수 (0) | 2023.03.27 |
cv2.cvtColor(): 색변환 함수 (0) | 2023.03.27 |