Resize Image using OpenCV

Resize Image using OpenCV

Image resizing reduces the number of pixels in an image. It can be useful when want to decrease image processing time or reduce the time of training of a neural network.

OpenCV provides the resize function which resizes the image down to or up by the specified width and height.

Python
C++
C++ (CUDA)
Java
import cv2 width = 320 height = 240 img = cv2.imread('test.jpg') resizedImg = cv2.resize(img, (width, height)) cv2.imshow('Original image', img) cv2.imshow('Resized image', resizedImg) cv2.waitKey(0) cv2.destroyAllWindows()

Result:

Resize Image using OpenCV

Leave a Comment

Cancel reply

Your email address will not be published.