How To Check Image Blur Or Not Using Python

Websolutionstuff | May-13-2022 | Categories : Python

In this article, we will see how to check image blur or not using python. For blur image check we are using the OpenCV package. OpenCV is a huge open-source library for computer vision, machine learning, and image processing. It can process images and videos to identify objects, faces, or even the handwriting of a human.

So, let's see blur detection in image python, Image blur detection in Python using OpenCV and imutils package, how to check blur image in python, python blur image OpenCV, blur image OpenCV python, image blur detection OpenCV python, openCV blur image detection python.

Step 1: Install PIP

In this step, we will install PIP. PIP is a package management system used to install and manage software packages written in Python. It stands for “preferred installer program” or “Pip Installs Packages.”

Download the get-pip.py file and store it in the same directory as python is installed.

python get-pip.py

So, check PIP installed using the below command.

pip -V

After installing pip we will install imutils and other needed packages.

pip install imutils

NumPy is the fundamental package for array computing with Python.

pip3 install numpy

Wrapper package for OpenCV python bindings.

pip install opencv-python

basic image processing functions such as translation, rotation, resizing, skeletonization, displaying Matplotlib images, sorting contours, detecting edges, and much easier with OpenCV and both Python 2.7 and Python 3.

 

 

Step 2: Write Python Script

Now, we will write the python script for image checking.

from imutils import paths

import argparse
import cv2
import sys

def variance_of_laplacian(image):
    return cv2.Laplacian(image, cv2.CV_64F).var()

#path of image URL
imagePath = sys.argv[1]	

image = cv2.imread(imagePath)

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

fm = variance_of_laplacian(gray)

text = "Image is not blurred..!"

if fm < 100:
    text = "Image is blurred..!"	
print text

Now, run the script.

python blur_detection.py -i images -t 100

 


You might also like :

Recommended Post
Featured Post
How to Convert UTC Time to Local Time in Laravel 11
How to Convert UTC Time to Loc...

Hello, laravel web developers! In this article, we'll see how to convert UTC time to local time in laravel 11. Here,...

Read More

Jul-03-2024

How to Check User Browser is Supported or Not in jQuery
How to Check User Browser is S...

In this article, we will see how to check user browser is supported or not in jquery. Some time latest features are not...

Read More

Nov-13-2020

How To Get Last Record In Laravel 8
How To Get Last Record In Lara...

In this example, we will see how to get the last record in laravel 8. You can simply get the last record using laravel 8...

Read More

Jan-26-2022

Top 12 Tips To Improve React JS Performance In 2023
Top 12 Tips To Improve React J...

In the dynamic world of web development, staying ahead of the curve is essential, and in 2023, React JS continues to be...

Read More

Aug-28-2023