# i can't uderstand the image blurring in following code....what does the following blurring filter do? how does it work?

2 Ansichten (letzte 30 Tage)
shawn am 19 Jul. 2012
i read the following code for a filter that blurs and then deblurs the image but the resultant blurring image is not expected... can you please explain why is it so? even though the deblurred result actually looks like the blurred expectation....
iBlur = Blurred result
iRes = restored
function h = generateFilter(s,img)
h = [];
[width,height] = size(img);
for y = 1:height
for x = 1:width
h(x,y) = (s/(2*pi))^(-s*sqrt(x^2+y^2));
end
end
% 'h' is the bluring filter
h = h / sum(sum(h)); % normalize
end
function [iRes,h] = applyBlurFilter(s,img);
iRes = [];
h = generateFilter(s,img);
H = fft2(h);
IMG = fft2(img);
I_BLUR = IMG .* H;
figure; imshow(uint8(I_BLUR));
iRes = ifft2(I_BLUR);
figure; imshow(uint8(iRes));
end
a = rgb2gray(a);
s = 0.2 % the value of s can be ranged from 0.1-0.5 to observe any sort of output....
applyBlurFilter(s,a)
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Walter Roberson am 19 Jul. 2012
You would have to tell us what you "expected".
It would probably also help if you described the difference between what you expected and what you got.

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Ryan am 20 Jul. 2012
Bearbeitet: Ryan am 20 Jul. 2012
I believe your unblurred is your expected blurred, and your blurred is actually the frequency domain for the blurred image. The filter is a Gaussian of some sort, I think it's an averaging filter due to the division by the sum(sum()).
Element wise division in the frequency domain with H will deblur it.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Image Analyst am 20 Jul. 2012
All you do is inverse FFT your blurred image, so of course it looks blurred back in the spatial domain. If you didn't want that you'd have to do an "inverse filter" by dividing your fourier domain image by H before you IFFT it.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Deblurring finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by