How to Resize an Image in Python

Spread the love

In this post, you will learn How to resize an image in python.

Resize an Image –

To resize an image, we can use resize method in OpenCV.

# import libraries
import cv2
import numpy as np
import matplotlib.pyplot as plt

# load image 
image = cv2.imread('maldives.jpg', cv2.IMREAD_GRAYSCALE)

# resize image to 50x50 pixel
image_50x50 = cv2.resize(image, (50, 50))

# view image
plt.imshow(image_50x50, cmap='gray')

Rating: 1 out of 5.

Leave a Reply