![]() |
Normalization involves adjusting the range of pixel intensity values in an image. Normalization can be beneficial for various purposes, such as improving the contrast or making the image more suitable for processing by other algorithms. In this article, we will explore how to normalize images using OpenCV in Python. What is Image Normalization?Image normalization is the process of adjusting the pixel intensity values of an image to a predefined range. This range is typically between 0 and 255 for images with 8-bit depth, where 0 represents black and 255 represents white. 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. This function allows us to specify the desired range for the pixel intensity values. Normalize an Image in OpenCV PythonBelow are some of the examples by which we can understand about normalizing images in OpenCV Python: Example 1: Normalizing Grayscale ImageIn this example, a grayscale image is read and normalized to enhance contrast using the NORM_MINMAX normalization method. Both the original and normalized images are displayed using OpenCV imshow() function.
Output: Example 2: Normalizing Color ImageIn this example, a color image is converted to grayscale, then normalized to enhance contrast. The normalized grayscale image is converted back to color and displayed alongside the original image using OpenCV.
Output: |
Reffered: https://www.geeksforgeeks.org
AI ML DS |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 17 |