VOOZH about

URL: https://www.analyticsvidhya.com/blog/2020/09/how-to-perform-blur-detection-using-opencv-in-python/

⇱ Blur Dection using OpenCV in Python | Identify Blurry photos in your Album


India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Reading list

How to perform Blur Detection using OpenCV in Python

Guest Blog Last Updated : 14 Sep, 2020
4 min read

Introduction

👁 Blur Detection

I probably have nearly ten thousand photos in my gallery. Of these, I thought at least 300–400 photos were blurry (there are 378 blurry photos in my gallery). “How can I handle this?” When I thought, it came to my mind that I was a software engineer. I immediately finished my walk and went back home and sat down at my computer and made a small project called “Blur Detection” that I will tell you below.

1 1 11 -8 11 1 1
4 5 63 3 82 1 7
4 5 63 12 82 1 7
import cv2
import argparse
import glob
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)
	cv2.waitKey(0)
python blur_detection.py -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.

Login to continue reading and enjoy expert-curated content.

Free Courses

Ensemble Learning and Ensemble Learning Techniques

Learn ensemble learning, its techniques, and how it works in this course!

Nano Course: Dreambooth-Stable Diffusion for Custom Images

Learn to create custom images with Dreambooth Stable Diffusion technology

Dimensionality Reduction for Machine Learning

Master key dimensionality reduction techniques for ML success!

Responses From Readers

ganesh

hI Model and final line "python blur_detection.py -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 ?

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
👁 Av Logo White

Continue your learning for FREE

Forgot your password?
👁 Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

👁 Popup Banner
👁 AI Popup Banner