Normalize an Image Using OpenCV in Python

In this tutorial, we will introduce the way to normalize an image using python opencv.

1. Inport libraries

import cv2 as cv
import numpy as np

2. Read an image

img = cv.imread('cate.jpeg')

3. Normalize an image

We will use cv.normalize() to normalize an image.

norm_img = np.zeros((800,800))
final_img = cv.normalize(img,  norm_img, 0, 255, cv.NORM_MINMAX)

4. Show normalized image

cv.imshow('Normalized Image', final_img)
cv.imwrite('city_normalized.jpg', final_img)
cv.waitKey(0)
cv.destroyAllWindows()