내가 보려고 만든 블로그

OpenCV를 사용한 이미지 크기 조정(python) 본문

OpenCV/python

OpenCV를 사용한 이미지 크기 조정(python)

hjh1023 2024. 5. 29. 18:58
반응형

resizeImg.py 

# let's start with the Imports 
import cv2
import numpy as np
 
# Read the image using imread function
image = cv2.imread('Lenna.png')
cv2.imshow('Original Image', image)
 
# let's downscale the image using new  width and height
down_width = 300
down_height = 200
down_points = (down_width, down_height)
resized_down = cv2.resize(image, down_points, interpolation= cv2.INTER_LINEAR)
 
# let's upscale the image using new  width and height
up_width = 800
up_height = 600
up_points = (up_width, up_height)
resized_up = cv2.resize(image, up_points, interpolation= cv2.INTER_LINEAR)
 
# Display images
cv2.imshow('Resized Down', resized_down)
cv2.waitKey()
cv2.imshow('Resized Up', resized_up)
cv2.waitKey()
 
#press any key to close the windows
cv2.destroyAllWindows()

 

 

 

반응형