Log in

View Full Version : Undoing gaussian blur convolution


luquinhas0021
1st January 2016, 14:57
The gaussian blur can be seen like a matrix convolution, with this coeficients depending of it size and the deviation. Is possible invert this matrix and restore the original pixel values, right? In case of unknow deviation, an iterative gaussian blur deconvolution, what artifacts may be generated in case of high deviation or big matrix size?

feisty2
1st January 2016, 15:20
https://en.wikipedia.org/wiki/Wiener_deconvolution

luquinhas0021
1st January 2016, 15:54
This filter works in frequency domain. The gaussian blur works in spatial domain. The inverse filtering works in frequency domain too. My idea is apply the inverse of gaussian blur in spatial domain. I`m just asking myself if my idea won`t destroy the medium-heavy noise images (not only make the noise sharper, but increase the number of speckles too). And if this idea will be able to recover lost details. Someone has an idea?

raffriff42
3rd January 2016, 16:35
"estimating a convolution kernel from a blurred and sharp image and
using the estimated kernel to deconvolve the blurred image (http://www.general-cathexis.com/Exercises/exercise4/index.html)"
(hmmm, no magically recovered lost detail though)

EDIT I should explain. The website general-cathexis.com (http://www.general-cathexis.com/) offers "SAR Image Processor,"
a free program that performs the interpolation methods shown in their well-known
Comparisons of Image Magnification Methods (http://www.general-cathexis.com/interpolation/) ("clown on bike") page and more,
including the above.

luquinhas0021
4th January 2016, 03:27
https://en.m.wikipedia.org/wiki/Gaussian_blur If you look at first set of images, you will see, in standard deviation 3 of gaussian kernel, the image gets blurred and lost some details. Would be possible recover it in proper gaussian blur`s deconvolution? One interesting question: from gaussian function (in that we include the deviation), the convolution matrix is created. This matrix depends only of the gaussian function and of the size of matrix or it depends of the image too?

raffriff42
4th January 2016, 04:35
https://en.wikipedia.org/wiki/Deblurring
https://en.wikipedia.org/wiki/Point_spread_function
https://en.wikipedia.org/wiki/Optical_transfer_function#Digital_inversion_of_the_optical_transfer_function
https://en.wikipedia.org/wiki/Blind_deconvolution

MATLab (http://www.mathworks.com)
http://www.mathworks.com/help/images/image-restoration-deblurring.html
https://www.dropbox.com/s/clcm7ivzr70bj7l/deblurring-matlab1.png?raw=1

ImageMagick (http://www.imagemagick.org/)
http://www.fmwconcepts.com/imagemagick/fftdeconvol/index.php
https://www.dropbox.com/s/agow5h44ed51xgs/deblurring-freds-imagemagick-fftdeconvol.png?raw=1


...now get to work.

pandy
4th January 2016, 15:48
The gaussian blur can be seen like a matrix convolution, with this coeficients depending of it size and the deviation. Is possible invert this matrix and restore the original pixel values, right? In case of unknow deviation, an iterative gaussian blur deconvolution, what artifacts may be generated in case of high deviation or big matrix size?

try it (very useful software btw):
http://meesoft.logicnet.dk/Analyzer/

rvs75
5th January 2016, 11:08
Smart Deblur 1.27
https://github.com/Y-Vladimir/SmartDeblur

Version 2+ are commercial.

raffriff42
5th January 2016, 15:08
SmartDeblur (thanks rvs75), commercial version. There is a free trial download.
There are some good articles on the site as well.
http://smartdeblur.net/

http://smartdeblur.net/images/Defocus_300.png
http://smartdeblur.net/images/Gaussian_300.png

luquinhas0021
7th January 2016, 21:27
Raffriff42, in last set of images (Results of SmartDeblur 2+), there's, in first pair of images, a like rainbow artifact in deblurred image. Some idea of why it happens? I've already used this software and, in images I have had in computer, the software made much more a strong sharpening with noise than deblur. Maybe I didn't configure right. After, I will re-download the SmartDeblur 2+. Thank you for opinion!

colours
8th January 2016, 19:28
Rainbowing happens because the deconvolution algorithm doesn't regularise against hue variation (or doesn't regularise enough).

But, y'know, some preliminary information. The discrete Fourier transform allows us to consider the spatial domain and the frequency domain as being dual to each other, and it converts convolution in the spatial domain to pointwise multiplication in the frequency domain.

A Gaussian blur is a convolution with a Gaussian kernel, and the Gaussian kernel has the interesting property that, up to scaling, it is its own Fourier transform. (In the discrete case, this is only approximately correct, but it's still close enough for our purposes.) This means that at high frequencies, the FT of the Gaussian kernel gets very close to zero, and when we convolve with the Gaussian kernel, we're essentially multiplying the high-frequency parts of the DFT of our source image with numbers close to zero.

Deconvolution (of the non-blind variety) corresponds to division in the frequency domain, and to undo a Gaussian blur is to take all these values close to zero (DFT of our input) and divide them by other values close to zero (FT of the Gaussian kernel). This is a horribly ill-posed problem, and the slightest imperfections in the blurred input (rounding error, noise, etc.) will be amplified thousandfold in the result. This is what regularisation (https://en.wikipedia.org/wiki/Regularization_%28mathematics%29) is for, which is to impose a cost on images that don't look "natural" enough; by optimising over some combination of the deconvolution error (i.e. the difference between input and convolve(deconvolve(input))) and an arbitrary regularisation term, we can get results that are much more visually pleasing.

tl;dr:

>The gaussian blur can be seen like a matrix convolution
Convolving with a 2D kernel is not matrix multiplication and there's no benefit to treating a kernel as a matrix. It's just a plain two-dimensional array.

>Is possible invert this matrix and restore the original pixel values, right?
If your blurred image has high enough precision and accuracy, yes. Otherwise, it's a crapshoot.

>The inverse filtering works in frequency domain too. My idea is apply the inverse of gaussian blur in spatial domain.
Same difference.

>And if this idea will be able to recover lost details.
No. Deconvolution can enhance attenuated detail, but detail that has been subsumed by rounding error is practically impossible to recover.