This package contains code to perform blind deblurring of non-uniform / spatially-varying blur caused by camera shake, using the model described in (1), applied within the algorithm described in (2) and (3). Please cite these three papers if using this code in an academic publication.
Please send bug reports to oliver.whyte@ens.fr
cd
to the code
directory, and run
mex_all
code
directory to your Matlab pathcd
to results
directorycode
directory is on the Matlab pathdeblur_...
deblur_...
script has a few components:
CONFIG_FNAME
for the name of the directory where the outputs
will goNON_UNIFORM = 1 / 0
for non-uniform / uniform blur modelimage_settings_...
script, which contains per-image
settingsdefault_config
script, which sets a lot of parameters to
their default valuesdeblur
script, which runs the actual algorithmpantheon
example takes 3 1/2 hours on my
workstation, with NUM_THREADS = 4
(see below)Please see the original readme from Fergus et al.’s code for an explanation of more options, and more information on the algorithm in general.
PRESCALE
Factor to downsample original blurry image.
BLUR_KERNEL_SIZE
Size of blur in blurry image after downsampling by PRESCALE
.
blur_{x,y,z}_lims = [min, max]
Maximum extent of blur due to contributions of , ,
and . Usually derived from BLUR_KERNEL_SIZE
.
focal_length_35mm
Camera’s focal length in 35mm equivalent. This is sometimes available
directly in the EXIF tags of an image. If not, the actual focal length
should be in the EXIF tags. With this, you will need to know the size of
the camera’s sensor in mm (you might try looking on
http://www.dpreview.com/reviews/specs.asp). Then,
focal_length_35mm = focal_length / sensor_width_in_mm * 36
.
AXIS = [xmin, xmax, ymin, ymax]
Region of (downsampled) blurry image to use for kernel estimation.
FIRST_INIT_MODE_BLUR = 'xbar' / 'ybar' / 'zbar'
Initialisation of kernel, depending on approximate shape of blur. One of 3
axes: xbar
for approximately vertical blur, ybar
for horizontal, or
zbar
for in-plane rotation.
DISPLAY_EACH_ITERATION = true / false
After each iteration, show the latent image and kernel, and plot the value of the cost function over all iterations.
SAVE_EACH_ITERATION = true / false
Save images of the latent image and kernel after each iteration. Note that this option will cause hundreds of (small) image files to be saved in the results directory.
PLOT_LINESEARCH = true / false
At each iteration, show value of cost function at different points along search direction.
NUM_THREADS
On systems where libpthread is available, the non-uniform blur model can
be run multi-threaded for speed. On other systems, NUM_THREADS
must be
set to 1.
We would like to thank Rob Fergus for making his code available online (http://cs.nyu.edu/~fergus/research/deblur.html) and for kindly allowing us to release our modified version of his code, as well as James Miskin and David MacKay for also making their original code available online (http://www.inference.phy.cam.ac.uk/jwm1003/).
Thanks to Xianyong Fang for testing and debugging the mex files on Windows.
The code in this package is based on the code provided by Fergus et al., and as such several parts are subject to their own license. For functions originally distributed by Fergus et al., please see the original readme from Fergus et al.’s code for details. These functions are marked with the header:
Author: Rob Fergus (or other)
Version: 1.0, distribution code.
Project: Removing Camera Shake from a Single Image, SIGGRAPH 2006 paper
Copyright 2006, Massachusetts Institute of Technology
For other functions marked with the header:
Author: Oliver Whyte <oliver.whyte@ens.fr>
Date: August 2010
Copyright: 2010, Oliver Whyte
Reference: O. Whyte, J. Sivic, A. Zisserman, and J. Ponce.
``Non-uniform Deblurring for Shaken Images''. In Proc. CVPR, 2010.
URL: http://www.di.ens.fr/~whyte/deblurring/
the following license applies:
Copyright (c) 2010, Oliver Whyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Bibliography
[1] O. Whyte, J. Sivic, A. Zisserman, and J. Ponce. “Non-uniform Deblurring for Shaken Images”. In Proc. CVPR, 2010.
[2] R. Fergus, B. Singh, A. Hertzmann, S. T. Roweis, and W. T. Freeman. “Removing camera shake from a single photograph”. ACM Trans. Graphics (Proc. SIGGRAPH 2006), 2006.
[3] J. W. Miskin and D. J. C. MacKay. “Ensemble Learning for Blind Image Separation and Deconvolution”. In Advances in Independent Component Analysis, 2000.