File:Deconvolution with imperfect kernels.png

Summary

Description
English: If you know the response function of your instrument, you can deconvolve it from your measurement to obtain a much sharper signal. But deconvolution is a dangerous procedure, as small mistakes in the kernel can result in heavy artifacts.
Date
Source https://twitter.com/j_bertolotti/status/1126058724722917377
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 11.0 code

data = Abs[ExampleData[{"TestImage", "Tree"}, "GrayLevels"] - 1];
size = Dimensions[data][[1]];
kernel = RotateRight[
   PadRight[GaussianMatrix[30], {size, size}], {-30, -30}];
cd = InverseFourier[Fourier[data]*Conjugate[Fourier[kernel]]];
ikernel = kernel; ikernel[[20, 20]] = Max[kernel];
nkernel = 
  RotateRight[
   PadRight[
    GaussianMatrix[30]*RandomReal[{0.5, 1.5}, {61, 61}], {size, size}], {-30, -30}];
p1 = Grid[{{ ArrayPlot[cd, Frame -> False], "deconvolved\n   with", ArrayPlot[RotateRight[kernel, {size/2, size/2}] , PlotLabel -> "Perfect kernel"], "\[Rule]", ArrayPlot[InverseFourier[Fourier[cd]/Conjugate[Fourier[kernel]]], Frame -> False]},
   { ArrayPlot[cd, Frame -> False], "deconvolved\n   with", ArrayPlot[RotateRight[ikernel, {size/2, size/2}]  , PlotLabel -> "Imperfect kernel\n(one pixel wrong)"], "\[Rule]", 
    ArrayPlot[InverseFourier[Fourier[cd]/Conjugate[Fourier[ikernel]]], Frame -> False]},
   { ArrayPlot[cd, Frame -> False], "deconvolved\n   with", ArrayPlot[RotateRight[nkernel, {size/2, size/2}], 
     PlotLabel -> "Imperfect kernel\n(noisy)" ], "\[Rule]", ArrayPlot[InverseFourier[Fourier[cd]/Conjugate[Fourier[nkernel]]], Frame -> False]}
   }, Alignment -> {Center, Center, {{1, 1} -> Bottom, {2, 1} -> Bottom, {3, 1} -> Bottom, {1, 5} -> Bottom, {2, 5} -> Bottom, , {3, 5} -> Bottom}}]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Deconvolution%20with%20imperfect%20kernels.pngCategory:Self-published work
Category:Deconvolution Category:Image processing Category:Images with Mathematica source code
Category:CC-Zero Category:Deconvolution Category:Image processing Category:Images with Mathematica source code Category:Self-published work