All Projects → Utkarsh-Deshmukh → Spatially-Varying-Blur-Detection-python

Utkarsh-Deshmukh / Spatially-Varying-Blur-Detection-python

Licence: BSD-2-Clause license
python implementation of the paper "Spatially-Varying Blur Detection Based on Multiscale Fused and Sorted Transform Coefficients of Gradient Magnitudes" - cvpr 2017

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Spatially-Varying-Blur-Detection-python

PaQ-2-PiQ
Source code for "From Patches to Pictures (PaQ-2-PiQ): Mapping the Perceptual Space of Picture Quality"
Stars: ✭ 63 (+46.51%)
Mutual labels:  image-quality, image-quality-assessment
No-Reference-Image-Quality-Assessment-using-BRISQUE-Model
Implementation of the paper "No Reference Image Quality Assessment in the Spatial Domain" by A Mittal et al. in OpenCV (using both C++ and Python)
Stars: ✭ 137 (+218.6%)
Mutual labels:  image-quality, image-quality-assessment
CONTRIQUE
Official implementation for "Image Quality Assessment using Contrastive Learning"
Stars: ✭ 33 (-23.26%)
Mutual labels:  image-quality, image-quality-assessment
rainbowify
Fabric mod for rainbow and blur backgrounds in minecraft guis
Stars: ✭ 18 (-58.14%)
Mutual labels:  blur
FocusLiteNN
Official PyTorch and MATLAB implementations of our MICCAI 2020 paper "FocusLiteNN: High Efficiency Focus Quality Assessment for Digital Pathology"
Stars: ✭ 28 (-34.88%)
Mutual labels:  image-quality-assessment
geeSharp.js
Pan-sharpening in the Earth Engine code editor
Stars: ✭ 25 (-41.86%)
Mutual labels:  image-quality
WaDIQaM
[unofficial] Pytorch implementation of WaDIQaM in TIP2018, Bosse S. et al. (Deep neural networks for no-reference and full-reference image quality assessment)
Stars: ✭ 119 (+176.74%)
Mutual labels:  image-quality-assessment
blur-up
A tool that creates preview images.
Stars: ✭ 28 (-34.88%)
Mutual labels:  blur
frosted-glass
❄️ Add a live frosted glass blur effect over any type of web content, including text.
Stars: ✭ 62 (+44.19%)
Mutual labels:  blur
metal camera
iOS metal camera with GPU shaders.
Stars: ✭ 68 (+58.14%)
Mutual labels:  blur
blurdialog
A dialog providing a blur effect as background, a title and an icon
Stars: ✭ 72 (+67.44%)
Mutual labels:  blur
Friendly Code Editor
Try this Friendly Code Editor. You'll love it. I made it with a lot of effort. It has some great features. I will update it adequately later. Very helpful for developers. Enjoy and share.
Stars: ✭ 20 (-53.49%)
Mutual labels:  blur
VaKawaseBlur
Fast and furious Kawase blur implementation for Unreal Engine 4
Stars: ✭ 37 (-13.95%)
Mutual labels:  blur
BVQA Benchmark
A resource list and performance benchmark for blind video quality assessment (BVQA) models on user-generated content (UGC) datasets. [IEEE TIP'2021] "UGC-VQA: Benchmarking Blind Video Quality Assessment for User Generated Content", Zhengzhong Tu, Yilin Wang, Neil Birkbeck, Balu Adsumilli, Alan C. Bovik
Stars: ✭ 93 (+116.28%)
Mutual labels:  image-quality-assessment
BlurKit
A lightweight library that can easily blur the view.
Stars: ✭ 17 (-60.47%)
Mutual labels:  blur
Blurberry
Transparent blur using UIVisualEffectView without subclassing
Stars: ✭ 46 (+6.98%)
Mutual labels:  blur
spark-convolution-patch
Convolution and other super-patches (blur, sharpen)
Stars: ✭ 74 (+72.09%)
Mutual labels:  blur
blurhash
Blurhash encoder/decoder algorithm implemenation in Nim.
Stars: ✭ 26 (-39.53%)
Mutual labels:  blur
cpu-gbfilter
♨️ Optimized Gaussian blur filter on CPU.
Stars: ✭ 14 (-67.44%)
Mutual labels:  blur
Xamarin.BlurView
Dynamic iOS-like blur of underlying Views for Android.
Stars: ✭ 26 (-39.53%)
Mutual labels:  blur

Efficient-Spatially-Varying-Blur-Detection-python

python implementation of the paper "Spatially-Varying Blur Detection Based on Multiscale Fused and Sorted Transform Coefficients of Gradient Magnitudes" - cvpr 2017

NOTE: This project outputs regions in an image which are sharp and blurry. In order to perform "OUT-OF-FOCUS" blur estimation, please refer to this repo: https://github.com/Utkarsh-Deshmukh/Blurry-Image-Detector

Brief Theory:

  • The repo is a python implementation of the paper which can be found here link to the paper
  • The discrete cosine transform is used to convert the image from spatial domain to frequency domain.
  • The DCT coefficients are divided into 'low', 'medium' and 'high' frequency bands, out of which only the high frequencies are used.
  • At a particular location, the high frequency DCT coefficients are extracted at various resolutions. All these selected coefficients are combined together and sorted to form the multiscale-fused and sorted high-frequency transform coefficients
  • these coefficients show a visual difference for blurry vs sharp patches in the image (refer to fig 2 in the paper)
  • each of these coefficients results in the generation of a "filtered layer" for the image. The first layer is the smallest DCT high frequency coefficient while the last layer is the highest DCT high frequency coefficient at various scales. (refer to secion 2.1 in the paper)
  • The union of a subset of these layers is selected. This is then sent through a max pooling to retain the highest activation from the set of layers
  • This resultant map is then sent for post processing which involves computing the local entropy and smoothing this local entropy map using a edge retaining smoothing filter such as Domain transform recursive edge-preserving filter. A guided filter can also be used here.
  • The Domain transform recursive edge-preserving filter was proposed in 2011 and can be found here: link to the paper

Installation and Running an example:

method 1 - use the library:

pip install blur_detector

import blur_detector
import cv2
if __name__ == '__main__':
    img = cv2.imread('image_name', 0)
    blur_map = blur_detector.detectBlur(img, downsampling_factor=4, num_scales=4, scale_start=2, num_iterations_RF_filter=3)

    cv2.imshow('ori_img', img)
    cv2.imshow('blur_map', blur_map)
    cv2.waitKey(0)

Results


Detecting Depth of field:

image

Detecting various types of blurs:

image image image

Algorithm overview:

image

Development/Testing Environment

This repository uses poetry as a package manager

Make sure your python version is >= 3.7
python --version

# Install poetry if you don't have it
python -m pip install poetry

# Install dependencies in a virtual environment
poetry install 
(This will install all locked dependencies from poetry.lock file)

# Activate virtual environment
poetry shell (Now you have a virtual environment with all dependencies)
Alternatively, to avoid creating a new shell, you can manually activate the virtual environment by running `source {path_to_venv}/bin/activate`
To get the path to your virtual environment run `poetry env info --path`. You can also combine these into a nice one-liner, `source $(poetry env info --path)/bin/activate`. To deactivate this virtual environment simply use `deactivate`.

# Using poetry run
To run your script simply use poetry run python your_script.py. This will automatically run your script in above created shell   

# Specifying dependencies
If you want to add dependencies to this project, you can specify them in the `tool.poetry.dependencies` section.

For example;

[tool.poetry.dependencies]
pendulum = "^1.4"

As you can see, it takes a mapping of package names and version constraints.
Poetry uses this information to search for the right set of files in package "repositories" that you register in the tool.poetry.repositories section, or on PyPI by default. 
Also, instead of modifying the pyproject.toml file by hand, you can use the add command.

poetry add pendulum

It will automatically find a suitable version constraint and install the package and subdependencies.


Publish to Pypi

Before you can actually publish your library, you will need to package it.

poetry build

This command will package your library in two different formats: sdist which is the source format, and wheel which is a compiled package. Once that is done you are ready to publish your library.

Poetry will publish to PyPI by default. Anything that is published to PyPI is available automatically through Poetry.

To share blur_detection library with the Python community, we would publish on PyPI as well. Doing so is really easy.

poetry publish

This will package and publish the library to PyPI, at the condition that you are a registered user and you have configured your credentials properly.


Acknowledgements

This algorithm is based on the paper: Spatially-Varying Blur Detection Based on Multiscale Fused and SortedTransform Coefficients of Gradient Magnitudes The paper can be found here: https://arxiv.org/pdf/1703.07478.pdf

The author would like to thank Dr. Alireza Golestaneh (This code is a python implementation of his work. His original work is an Matlab and can be found here: https://github.com/isalirezag/HiFST)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].