How to identify the quality of an image using OpenCV

share link

by Dejaswarooba dot icon Updated: Mar 21, 2023

technology logo
technology logo

Solution Kit Solution Kit  

Known as OpenCV, this software library for computer vision and machine learning is free and open source. A standard infrastructure for computer vision applications was created with OpenCV to speed up the incorporation of artificial intelligence into products. All algorithms in OpenCV are C++-implemented. But, these techniques can be utilized with various languages, including Python, Java, etc. The bindings generators allow for this. A collection of Python bindings called OpenCV-Python was created to address computer vision issues. 



Observers heavily influence the idea of image quality. It is typically related to the circumstances under which it is viewed, making it a highly subjective subject. Image quality evaluation aims to capture how people perceive quality quantitatively. These metrics are frequently used to evaluate algorithms' performance across various computer vision applications, including image compression, image transmission, and image processing. 



A second-order derivative filter called the Laplacian operator is used in image processing to find edges and other characteristics in a picture. Here, the Laplacian() function is used to measure the quality of an image. Enhancing the high-frequency and attenuating the low-frequency components of an image is used to improve the edges and details in pictures.

fig 1 - The image used to find quality of.

fig 2- Execution of the code.

fig 3- The output depicting the sharpness of the image.

Code


Two inputs are required for the cv2.Laplacian() method in OpenCV: the input picture ‘img’ and the data type ‘cv.CV 64F’, which specifies that the output image should contain floating point values.


The numpy array produced by the function cv2.Laplacian(img, cv.CV 64F) will have the same dimensions as the input picture img. The array's values correspond to the relevant pixel's Laplacian in the input image. In the Laplacian image, regions with positive values are those where the intensity is fast increasing, while regions with negative values are those where the intensity is rapidly falling. 0 values represent areas with a substantially stable intensity.


The average of this numpy array gives you the sharpness of the image.

1. Copy and paste the above code from Kandi.

2. Add another line of code ‘print(sharpness)’ to display the quality.

3. It is a better option to create a virtual environment while working with python.


I found this code snippet by searching for "How to identify the quality of an image using OpenCV" in kandi. You can try any such use case!

Dependent Libraries

opencv-pythonby opencv

Shell doticonstar image 3491 doticonVersion:72doticon
License: Permissive (MIT)

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.

Support
    Quality
      Security
        License
          Reuse

            opencv-pythonby opencv

            Shell doticon star image 3491 doticonVersion:72doticon License: Permissive (MIT)

            Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
            Support
              Quality
                Security
                  License
                    Reuse

                      If you do not have OpenCV that is required to run this code, you can install it by clicking on the above link and copying the pip Install command from the OpenCV page in kandi.


                      You can search for any dependent library on kandi like OpenCV.

                      Environment tested

                      1. This code had been tested using python version 3.8.0
                      2. opencv-python version 4.7.0 has been used.

                      Support


                      1. For any support on kandi solution kits, please use the chat
                      2. For further learning resources, visit the Open Weaver Community learning page.


                      See similar Kits and Libraries