# Blur Detection using OpenCV (Laplacian and FFT based approach)

After doing some computer vision projects I found some of the images taken from the camera in real-time are blurry. When I searched in google to identify blur detection using the OpenCV-based approach.

In below, I mentioned two approaches for blur detection using Fast Fourier Transform (FFT) and Laplacian

Fig Clear image vs Blurry image

Method 1

**Laplacian approach for blur detection**

The Laplace filter is mainly used to define the edge lines in a picture. What is meant here by the edge are the sharp color separations that usually separate objects from the background. The Laplace filter, also known as the Sharpening Filter, uses a window while operating.

Steps involved :

- Read the input RGB image for analysis
- Convert the RGB to the grayscale image
- Measure the variance using Laplacian
- Based on the focal measure score, apply the condition for blurry analysis.

Method 2:

**Fast Fourier Transform (FFT) for blur detection**

**T**he Fast Fourier Transform is a convenient mathematical algorithm for computing the Discrete Fourier Transform. It is used for converting a signal from one domain into another.

The FFT is useful in many disciplines, ranging from music, mathematics, science, and engineering.

In terms of computer vision, we often think of the FFT as an image processing tool that represents an image in two domains:

- Fourier (i.e., frequency) domain
- Spatial domain

Therefore, the FFT represents the image in both *real* and *imaginary* components.

By analyzing these values, we can perform image processing routines such as blurring, edge detection, thresholding, texture analysis, and *yes, even blur detection*

Adjust the threshold, based on mean values of FFT to determine blurry or not

*Code:*