Skip to content

venugopalkadamba/Image-Blur-Detection

Repository files navigation

Image Blur Detection using Machine Learning

QUESTION

Image quality detection has always been an arduous problem to solve in computer vision.
In this assignment you have to come up with features and models to build a classifier which will predict whether a given image is blurred.

APPROACH

We can classify whether a image is blurred or not by observing the edges in the image. One of the most commonly used method for detecting edges from the image is Laplacian method. The reason for using laplacian operator is its definition itself, laplacian operator is used to get the second derivatives of the images. The laplacian oprator highlights the regions where their is rapid change of intensity in the image. After applying the laplacian operator to the image we calculate the variance and maximum of the image pixels. The image with high variance and high maximum are expected to have sharp edges i.e.it's a clear image, whereas the image with less variance and less maximum are expected to be a blur image.
Deciding the threshold, below threshold the image is said to be blurred and above threshold the image is said to be clear, is a major task. We can tackle this problem by using machine learning algorithms. We can make use of variance and maximum as features for our machine learning model to predict whether the given image is a blur image or clear image.

NOTE: In all the python files Label 1 = 'Blur Image' and Label 0 = 'Clear Image'

STEPS FOR EXECUTING THE FILES

STEP-1: Install all the dependencies mentioned in requirements.txt file by running following command in command prompt

pip install -r requirements.txt

STEP-2: After installing all the dependencies, make sure that the dataset contains images in below mentioned paths

  • CERTH_ImageBlurDataset/TrainingSet/
    • Undistorted/
    • Naturally-Blurred/
    • Artificially-Blurred/
  • CERTH_ImageBlurDataset/EvaluationSet/
    • DigitalBlurSet/
    • NaturalBlurSet/
    • DigitalBlurSet.xlsx
    • NaturalBlurSet.xlsx

STEP-3: After completion of above two steps, for processing the images and generation of features, execute "image_processing_and_feature_generation.py" file in command prompt.

NOTE: Executing this file will take some time, this code is already executed and the generated csv files are already present in the folder. I recommend to skip execution of this step and proceed with next step.

python image_processing_and_feature_generation.py

After executing the above file, you can notice two csv files in current working directory "train.csv" and "validation.csv".

STEP-4: After executing the above command, execute "train_model.py" in command prompt

python train_model.py

After executing the above file, you can notice two pickle files in current working directory "XGBoost.pkl" and "voting_model.pkl".

STEP-5: After executing the above command, execute "validation.py" in command prompt to get the scores on evaluation dataset

python validation.py

After executing the above file, you can notice a pickle file "Final_Model.pkl" which got the highest validation accuracy.

RESULT

After execution of all steps, a model with 88% accuracy on evaluation set was generated. Both thhe XGBoost and Voting Classifier models performed well with same accuracy.
"Final_Model.pkl" is the final version of the model and can be used for predicting whether a image is blur image or clear image.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages