Code Monkey home page Code Monkey logo

polyblur's Introduction

Non-official Python Implementation of Polyblur

Slightly out-of-focus image Deblurred result with Polyblur

This repository contains a Python implementation of Polyblur: Removing mild blur by polynomial reblurring in IEEE Transaction on Computational Imaging 2021 by Mauricio Delbracio, Ignacio Garcia-Dorado, Soungjoon Choi, Damien Kelly and Peyman Milanfar. We provide Pytorch and Numpy non-official implementations reproducing the quantitative and qualitative results of the original paper.

A description an analysis of the algorithm can be found in a companion IPOL paper: Breaking down Polyblur: Fast blind Correction of Small Anisotropic Blurs in Image Processing OnLine 2022 by Thomas Eboli, Jean-Michel Morel and Gabriele Facciolo.

Test

First install the requirements with

pip install -r requirements.txt

Second install the module with

python setup.py install

The Pytorch implementation of this code runs ONLY with torch 1.10+ versions (because of torch.fft for the computation of the gradients with the pytorch implementation).

Once done, you can test the blind deblurring technique with

python main.py --impath ./pictures/peacock_defocus.png --N 3 --alpha 6 --beta 1

You can modify several parameters, e.g. the number of Polyblur iterations and the deconvolution filter's parameters alpha and beta

Description

After installation, the package is imported to any project with

import polyblur

The code contains functional and module blocks: The first is found in the path

polyblur.polyblur_deblurring

and is agnostic to (H,W,C) or (H,W) Numpy arrays or (B,C,H,W) Pytorch tensors. The latter inherits from torch.nn.module and either call deblurring.polyblur on the whole image or overlapping patches. This module is called with

polyblur.PolyblurDeblurring

Calibration

We also provide a code for reproducing the calibration curves of the original paper with our FFT-based implementation of the gradients, or any other one one can image. To compute the slope and intercept of the model, please run

python calibration_blur_parameters.py

Below is an example of the predicted curves for 1% additive Gaussian noise. If you use the exact same implementation of the gradients as in this repo, you should find something like (0.362, -0.468) for the affine model parameters. You should first provide the path to the DVI2K validation set.

Principal blur direction Orthogonal blur direction

Roadmap

This code reproduces the results of the TCI'22 article but is not as fast. Even though it is not the goal of this repository, here are some elements I will enhance in a near future:

  • polybur.domain_transform should be implemented with a C++ or CUDA-based normalized convolution to be faster.
  • the convolution are too slow with FFT. I should implement it with separable filters as in the TCI paper.

Contact

If you encounter any problem with the code, please contact me at [email protected].

polyblur's People

Contributors

teboli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.