How to Detect Low Contrast Images with OpenCV and scikit-image

In this lesson we want to learn How to Detect Low Contrast Images with OpenCV and scikit-image, for this we are using OpenCV and scikit-image.

 

What is OpenCV ?

OpenCV (Open Source Computer Vision Library) is library of computer vision and machine learning algorithms. It is written in C, C++ and Python and is available as an open source project under the BSD license.

OpenCV provides large collection of algorithms for tasks such as image processing, object detection, face recognition and many more. It is widely used in computer vision applications, including real time video processing, robotics and augmented reality. OpenCV also provides interfaces to integrate with other libraries and frameworks such as TensorFlow to extend its functionality.

 

To install OpenCV in Python, you can use the following pip command:

 

 

What is Skimage and How to Install ?

Scikit image (skimage) is an image processing Python library that includes algorithms for segmentation, color space conversion, feature detection and many more. It is built on top of NumPy, SciPy and Matplotlib, and is designed to work with 2D images represented as NumPy arrays.

To install scikit-image, you can use the following pip command:

 

 

Low contrast images can be detected using a combination of OpenCV and scikit image in Python. this is an example of how to do it:

In this example we have first loaded image using OpenCV’s imread function. after that we have converted the image to grayscale using the cvtColor function. Next we calculate the mean and standard deviation of the grayscale image using the meanStdDev function. after that we normalized image using the mean and standard deviation which helps to correct the contrast of the image.

Next we use scikit image’s equalize_adapthist function to apply the adaptive histogram equalization to the image, which improves contrast even further. finally we check if the contrast of the image is low by calculating the standard deviation of the grayscale image and comparing it to a threshold value of 50. If the standard deviation is less than 50, we consider the image to have low contrast. (How to Detect Low Contrast Images with OpenCV and scikit-image)

 

Learn More on Python

Leave a Comment