Image deblurring using MATLAB

image-processing, matlab

Solution

I can recommend you a few ways to do that:

Arithmetic mean filter:

f = imfilter(g, fspecial('average', [m n]))

Geometric mean filter

f = exp(imfilter(log(g), ones(m, n), 'replicate')) .^ (1/(m*n))

Harmonic mean filter

f = (m*n) ./ imfilter(1 ./ (g + eps), ones(m, n), 'replicate');

where n and m are size of a mask (for instance, you can set `m = 3` `n = 3`)

Problem

I have two images, one is degraded and one is part of the original image. I need to enhance the first image by using the second one, and I need to do this in the frequency domain. I cut the same area from the degraded image, took its FFT, and tried to calculate the transfer function, but when I applied that function to the image the result was terrible. So I tried `h=fspecial('motion',9,45);` to be my transfer function and then reconstructed the image with the code given below. ``` im = imread('home_degraded.png'); im = rgb2gray(im); h = fspecial('motion',9,45); H = zeros(519,311); H(1:7,1:7) = h; Hf = fft2(H); d = 0.02; Hf(find(abs(Hf)<d))=1; I = ifft2(fft2(im)./Hf); imshow(mat2gray(abs(I))) ``` I have two questions now: How can I generate a transfer function by using the small rectangles (I mean by not using `h=fspecial('motion',9,45);`)? What methods can I use to remove noise from an enhanced image?

Original source