Python Script: Check image blur or not.

In this tutorial, I will explain how to create how to check image blue or not.

Generally, In the OCR field, Users mostly uploads low-quality or poor images so this script will help to verify if the image blur or not.

You have to install python in your system so open your terminal and put the below code.

sudo apt install python-pip

After that you have to enter this command:

A series of convenience functions to make 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.

pip install imutils

After that you have to enter this command:

NumPy is the fundamental package for array computing with Python.

pip3 install numpy

And this is the last command you have to enter:

Wrapper package for OpenCV python bindings.

pip install opencv-python


After that you have open editor put the below code:

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 = "Not Blurry"
if fm < 100:
	text = "Blurry"	
print text

I hope it will help!

About Dhaval Shah

My name is Dhaval Shah. I'm a Laravel developer. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress, and Bootstrap.
Follow me on Github / Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!