algorithm - Inverse convolution of image -


i have source , result image. know, convolution matrix has been used on source result. can convolution matrix computed ? or @ least not exact one, similar.

in principle, yes. convert both images frequency space using fft , divide fft of result image of source image. apply inverse fft approximation of convolution kernel.

to see why works, note convolution in spatial domain corresponds multiplication in frequency domain, , deconvolution corresponds division in frequency domain. in ordinary deconvolution, 1 divide fft of convolved image of kernel recover original image. however, since convolution (like multiplication) commutative operation, roles of kernel , source can arbitrarily exchanged: convolving source kernel same convolving kernel source.

as other answers note, however, unlikely yield exact reconstruction of kernel, same reasons ordinary deconvolution won't reconstruct original image: rounding , clipping introduce noise process, , it's possible convolution wipe out frequencies (by multiplying them zero), in case frequencies cannot reconstructed.

that said, if original kernel of limited size (support), reconstructed kernel should typically have single sharp peak around origin, approximating original kernel, surrounded low-level noise. if don't know exact size of original kernel, shouldn't hard extract peak , discard rest of reconstruction.

example:

here's lenna test image in grayscale, scaled down 256×256 pixels , convolved 5×5 kernel in gimp:

originalkernelresult

i'll use python numpy/scipy deconvolution:

from scipy import misc numpy import fft  orig = misc.imread('lena256.png') blur = misc.imread('lena256blur.png') orig_f = fft.rfft2(orig) blur_f = fft.rfft2(blur)  kernel_f = blur_f / orig_f         # deconvolution kernel = fft.irfft2(kernel_f)      # inverse fourier transform kernel = fft.fftshift(kernel)      # shift origin center of image kernel /= kernel.max()             # normalize gray levels misc.imsave('kernel.png', kernel)  # save reconstructed kernel 

the resulting 256×256 image of kernel, , zoom of 7×7 pixel region around center, shown below:

reconstructed kernel zoom of reconstructed kernel

comparing reconstruction original kernel, can see pretty similar; indeed, applying cutoff anywhere between 0.5 , 0.68 reconstruction recover original kernel. faint ripples surrounding peak in reconstruction noise due rounding , edge effects.

i'm not entirely sure what's causing cross-shaped artifact appears in reconstruction (although i'm sure more experience these things tell you), off top of head, guess has image edges. when convolved original image in gimp, told handle edges extending image (essentially copying outermost pixels), whereas fft deconvolution assumes image edges wrap around. may introduce spurious correlations along x , y axes in reconstruction.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -