2012-12-05 63 views
2

我試圖使用高斯濾波器使用下面的代碼來遮擋圖像 但我知道我有一個問題,只要過濾器包含零,所以我想知道是否有其他方法的反捲積但使用FFT使用FFT的圖像解卷積

function [ out ] = imblur(file) 

img = im2double(imread(file)); 

h = fspecial('gaussian', [15 15], 3); 

img_red = img(:,:,1); 
img_blue = img(:,:,2); 
img_green = img(:,:,3); 


[m,n] = size(img_red); 
[mb,nb] = size(h); 

% output size 
mm = m + mb - 1; 
nn = n + nb - 1; 

x1(:,:,1) = (ifft2(fft2(img_red,mm,nn)./ fft2(h,mm,nn))); 
x2(:,:,2) = (ifft2(fft2(img_blue,mm,nn)./ fft2(h,mm,nn))); 
x3(:,:,3) = (ifft2(fft2(img_green,mm,nn)./ fft2(h,mm,nn))); 

out = cat(3, x1(:,:,1), x2(:,:,2), x3(:,:,3)); 

imshow(out); 
+0

你有沒有嘗試過這樣的:http://www.mathworks.in/help/images/ref/deconvblind.html – Kishore

+1

是的,但我想知道它是如何實現並採用FFT – Belbesy

+0

我認爲你正在做的是正確的。只是不打擾指定輸出大小。 fft函數的輸出將始終給出與輸入信號相同的大小,因爲它實際上實現了DFT。此外,您可能需要將信號長度除以信號的結果(不確定MATLAB是否自動執行)。 – Kishore

回答

0

與小量更換零工作就好了。

+0

工程「很好「:頁 – thang