as one can see at: http://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#cv2.normalize, there is a โ†’ dst that say that the result of the normalize function is returned as output parameter. The function doesn't change the input parameter dst in-place. (The self. in cv.imshow('dst_rt', self.normalizedImg) line is a typo)

import cv2 as cv
import numpy as np
path = r"C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg"
img = cv.imread(path)
normalizedImg = np.zeros((800, 800))
normalizedImg = cv.normalize(img,  normalizedImg, 0, 255, cv.NORM_MINMAX)
cv.imshow('dst_rt', normalizedImg)
cv.waitKey(0)
cv.destroyAllWindows()
Answer from Ophir Carmi on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ computer vision โ€บ normalize-an-image-in-opencv-python
Normalize an Image in OpenCV Python - GeeksforGeeks
July 23, 2025 - Normalization can be performed to improve the contrast of an image or to standardize the pixel values for further processing. In OpenCV Python, the normalize() function from the cv2 module is used to normalize images.
Discussions

python - Normalizing images in OpenCV produces black image? - Stack Overflow
I wrote the following code to normalize an image using NORM_L1 in OpenCV. But the output image was just black. How to solve this? import cv2 import numpy as np import Image img = cv2.imread('img7.... More on stackoverflow.com
๐ŸŒ stackoverflow.com
April 17, 2017
[Question] cv2.normalize behaviour in Python
What kind of normalization you want to get? More on reddit.com
๐ŸŒ r/opencv
6
5
March 24, 2020
cv2.normalize with NORM_MINMAX produces small values below set minimum on float32
OpenCV python version: 4.10.0 Operating System / Platform: macOS 15.1.1 arm64 M2 Python version: 3.9.6 (/usr/bin/python3 provided by macOS) The following code shows unexpected small negative numbers when trying to normalize an image between 0 and 1 while a comparison, which is mathematically ... More on github.com
๐ŸŒ github.com
25
December 7, 2024
keras - Normalizing images with OpenCV (divide by 255) - Data Science Stack Exchange
I'm loading images from my dataset, which are all of resolution 200x200 and in RGB format. I'm loading them using OpenCV for Python, with the following code: images = [] for image in os.listdir(pat... More on datascience.stackexchange.com
๐ŸŒ datascience.stackexchange.com
January 23, 2022
People also ask

What does cv2.normalize() do?
It transforms an input array to a requested range or norm and writes the result using the selected output and dtype policy.
๐ŸŒ
pythonpool.com
pythonpool.com โ€บ home โ€บ opencv โ€บ cv2.normalize() in python: scale images and arrays
cv2.normalize() in Python: Scale Images and Arrays
Can cv2.normalize() use a mask?
Yes. A mask limits which elements participate, so inspect the mask shape and verify whether the output outside the mask should remain unchanged or be handled separately.
๐ŸŒ
pythonpool.com
pythonpool.com โ€บ home โ€บ opencv โ€บ cv2.normalize() in python: scale images and arrays
cv2.normalize() in Python: Scale Images and Arrays
How do I normalize an image to 0-255?
Use cv2.normalize(src, None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX) and choose an output dtype suitable for display.
๐ŸŒ
pythonpool.com
pythonpool.com โ€บ home โ€บ opencv โ€บ cv2.normalize() in python: scale images and arrays
cv2.normalize() in Python: Scale Images and Arrays
๐ŸŒ
OpenCV
forum.opencv.org โ€บ python
How do i normalize an image better? - Python - OpenCV
February 15, 2021 - Hi, Im using a python script to recieve images from a depth camera and when i started reading in the values of each pixel i had to normalize it to actually display it with imshow() So i used this command to normalize my image: cv2.normalize(depth_array, depth_array, 0, 1, cv2.NORM_MINMAX) depth_array is a 2D numpy array that contains the values for each pixel.
๐ŸŒ
Python Pool
pythonpool.com โ€บ home โ€บ opencv โ€บ cv2.normalize() in python: scale images and arrays
cv2.normalize() in Python: Scale Images and Arrays
July 13, 2026 - Use cv2.normalize() for OpenCV image and array scaling with NORM_MINMAX, L1, L2, masks, alpha, beta, and dtype choices.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-normalize-an-image-in-opencv-python
How to normalize an image in OpenCV Python?
August 26, 2023 - Image normalization in OpenCV rescales pixel values to a specific range, improving image processing and machine learning model performance. The function provides various normalization techniques to transform pixel intensities.
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ programming languages tutorial โ€บ opencv normalize
OpenCV Normalize | Working of normalize() function in OpenCV
April 19, 2023 - The process in which we modify ... image and in order to perform image normalization, we make use of a function called normalize() function in OpenCV which returns the normalized image as the output based on the normalization ...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Find elsewhere
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ 5 best ways to normalize an image in opencv python
5 Best Ways to Normalize an Image in OpenCV Python - Be on the Right Side of Change
February 27, 2024 - It then performs min-max scaling and scales the pixel values to a new range specified by new_min and new_max. This method allows for more control over the normalization process. OpenCV offers a built-in function cv2.normalize for normalization, which can be a quick and easy one-liner solution.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ opencv normalize
How to Normalize Images in Python OpenCV | Delft Stack
March 11, 2025 - By normalizing images, we can ensure that the intensity values are consistent, which can lead to better performance in image analysis tasks. OpenCV provides a straightforward way to normalize images using the normalize() function, which can ...
๐ŸŒ
CodeSpeedy
codespeedy.com โ€บ home โ€บ normalizing an image in opencv python
Normalize an Image in OpenCV Python - CodeSpeedy
March 16, 2020 - import cv2 as cv import numpy as np img = cv.imread('city.jpeg') norm_img = np.zeros((800,800)) final_img = cv.normalize(img, norm_img, 0, 255, cv.NORM_MINMAX) cv.imshow('Normalized Image', final_img) cv.imwrite('city_normalized.jpg', final_img) ...
๐ŸŒ
Javatpoint
javatpoint.com โ€บ opencv-normalize-in-python
OpenCV Normalize in Python - Javatpoint
In this tutorial we are learning about the OpenCV Normalize in Python. The process in which we change the pixel values in the image to make the image more satisfactory is called image normalization.
๐ŸŒ
Tpoint Tech
tpointtech.com โ€บ opencv-normalize-in-python
OpenCV Normalize in Python - Tpoint Tech
April 16, 2026 - The Python library must be OpenCV in all of the examples below. Make sure you install it. Use the cv2.imread() method to read the input image into a grayscale image. Specify the full path to the image using the image format (e.g., png or jpg). Apply cv2.normalize() to the input image img.
๐ŸŒ
Videogames
videogames.ai โ€บ Normalize-image-opencv-python
How to normalize an image using opencv and python | videogames.ai
Itโ€™s quite easy with opencv. If you want to normalize to 0 to 1, for example to serve as input to a network network.
Top answer
1 of 3
84

If you want to change the range to [0, 1], make sure the output data type is float.

image = cv2.imread("lenacolor512.tiff", cv2.IMREAD_COLOR)  # uint8 image
norm_image = cv2.normalize(image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
2 of 3
25

The other answers normalize an image based on the entire image. But if your image has a predominant color (such as black), it will mask out the features that you're trying to enhance since it will not be as pronounced. To get around this limitation, we can normalize the image based on a subsection region of interest (ROI). Essentially we will normalize based on the section of the image that we want to enhance instead of equally treating each pixel with the same weight. Take for instance this earth image:

Input image -> Normalization based on entire image

If we want to enhance the clouds by normalizing based on the entire image, the result will not be very sharp and will be over saturated due to the black background. The features to enhance are lost. So to obtain a better result we can crop a ROI, normalize based on the ROI, and then apply the normalization back onto the original image. Say we crop the ROI highlighted in green:

This gives us this ROI

The idea is to calculate the mean and standard deviation of the ROI and then clip the frame based on the lower and upper range. In addition, we could use an offset to dynamically adjust the clip intensity. From here we normalize the original image to this new range. Here's the result:

Before -> After

Code

import cv2
import numpy as np

# Load image as grayscale and crop ROI
image = cv2.imread('1.png', 0)
x, y, w, h = 364, 633, 791, 273
ROI = image[y:y+h, x:x+w]

# Calculate mean and STD
mean, STD  = cv2.meanStdDev(ROI)

# Clip frame to lower and upper STD
offset = 0.2
clipped = np.clip(image, mean - offset*STD, mean + offset*STD).astype(np.uint8)

# Normalize to range
result = cv2.normalize(clipped, clipped, 0, 255, norm_type=cv2.NORM_MINMAX)

cv2.imshow('image', image)
cv2.imshow('ROI', ROI)
cv2.imshow('result', result)
cv2.waitKey()

The difference between normalizing based on the entire image vs a specific section of the ROI can be visualized by applying a heatmap to the result. Notice the difference on how the clouds are defined.

Input image -> heatmap

Normalized on entire image -> heatmap

Normalized on ROI -> heatmap

Heatmap code

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

image = cv2.imread('result.png', 0)
colormap = plt.get_cmap('inferno')
heatmap = (colormap(image) * 2**16).astype(np.uint16)[:,:,:3]
heatmap = cv2.cvtColor(heatmap, cv2.COLOR_RGB2BGR)

cv2.imshow('image', image)
cv2.imshow('heatmap', heatmap)
cv2.waitKey()

Note: The ROI bounding box coordinates were obtained using how to get ROI Bounding Box Coordinates without Guess & Check and heatmap code was from how to convert a grayscale image to heatmap image with Python OpenCV

๐ŸŒ
Reddit
reddit.com โ€บ r/opencv โ€บ [question] cv2.normalize behaviour in python
r/opencv on Reddit: [Question] cv2.normalize behaviour in Python
March 24, 2020 -

I'm trying to understand the behaviour in python of the cv2.normalize function.
Specifically code such as this

n = t_new

cv2.normalize(t_new, n)

which can be found in this python code at edge_tangent_flow.py
I'm trying to replicate the behaviour in Java with opencv and ND4J but nothing I try seems to match this functions results.

Thanks

๐ŸŒ
GitHub
github.com โ€บ opencv โ€บ opencv โ€บ issues โ€บ 26588
cv2.normalize with NORM_MINMAX produces small values below set minimum on float32 ยท Issue #26588 ยท opencv/opencv
December 7, 2024 - #!/usr/bin/env python3 import cv2 import numpy as np m = np.array([[ 1888, 1692, 369, 263, 199, 280, 326, 129, 143, 126, 233, 221, 130, 126, 150, 249, 575, 574, 63, 12]], dtype=np.float32) print(cv2.__version__) print(m.min(axis=(0, 1)), m.max(axis=(0, 1))) mn = cv2.normalize(m, None, 0, 1, norm_type=cv2.NORM_MINMAX) print(mn.min(axis=(0, 1)), mn.max(axis=(0, 1))) ... I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
Author: opencv
๐ŸŒ
Stack Exchange
datascience.stackexchange.com โ€บ questions โ€บ 107391 โ€บ normalizing-images-with-opencv-divide-by-255
keras - Normalizing images with OpenCV (divide by 255) - Data Science Stack Exchange
January 23, 2022 - I'm loading them using OpenCV for Python, with the following code: images = [] for image in os.listdir(path): image = cv2.imread(str(path)+"/"+str(image)) image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB) images.append(image) images = np.array(images) and the code is working just fine. However, what I'm trying to do next is normalize the images by diving their color information by 255, to get numbers between 0 and 1 for later use in CNN.
๐ŸŒ
OpenCV Q&A Forum
answers.opencv.org โ€บ question โ€บ 77466 โ€บ help-with-normalising
Help with normalising - OpenCV Q&A Forum
I don't understand your problem. If you use the max() and min() functions like above, you end up with an array with values between 7000 and 9000. If then you call cv2.normalize(image, image, 0, 65536, cv2.NORM_MINMAX), the result is what you're expected, I think.
๐ŸŒ
YouTube
youtube.com โ€บ watch
OPENCV & C++ TUTORIALS - 106 | normalize() | Normalize Images - YouTube
If youโ€™d like to buy me a coffee โ˜•๐Ÿ‘‰ https://buymeacoffee.com/yunustemurlenkThe normalize function in OpenCV is used to scale and shift pixel values in image
Published: August 21, 2023