guest_blog — Updated On September 14th, 2020
Advanced Computer Vision Deep Learning Image Python Unstructured Data


Blur Detection

Blur detection

1  1 11 -8 11  1 1
4 5 63 3 82 1 7
4 5 63 12 82 1 7

Blur detection

Image for post

import cv2
import argparse
import glob

Image for post

ap = argparse.ArgumentParser()
ap.add_argument('-i', '--images', required=True,)
ap.add_argument('-t', '--threshold', type=float)
args = vars(ap.parse_args())

To keep the images in the folder in a single array, we write the following code:

images = [cv2.imread(file) for file in glob.glob("{}/*.jpeg".format(args['images']))]

Now it is time to take the pictures in the folder one by one and apply the Laplacian method to find blur.

for image in images:
	gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
	fm = cv2.Laplacian(gray, cv2.CV_64F).var()
	text = "Not Blurry"

	if fm < args["threshold"]:
		text = "Blurry"

	cv2.putText(image, "{}: {:.2f}".format(text, fm), (10, 30),
		cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 3)
	cv2.imshow("Image", image)
python -i images -t 100

Author - Blur detection

Muhammed Furkan Gülşen

I have been a web developer for over 5 years. First, I continued as a Frontend developer. Later, I learned Backend and continued to improve myself as a FullStack developer. During this period, I managed projects as a Project Manager in the Facebook Developer Circle community. After doing this job for about 1 year, I received an offer from a company and switched to that company. I have been working in this company for more than 10 months, both as a full-stack developer and as a Data Scientist.While this process was going on (for the last 2 years) I started data science. Later the process continued as machine learning, deep learning, image processing, and finally Computer Vision.

One thought on "How to perform Blur Detection using OpenCV in Python"

ganesh says: September 16, 2020 at 11:52 pm
hI Model and final line "python -i images -t 100" , everything is running perfect in console but no result is coming ? output link is not opening ? how you open the output link ? Reply

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