【发布时间】:2012-12-05 15:55:37
【问题描述】:
我正在尝试使用以下代码使用高斯滤镜对图像进行盲目模糊处理 但我知道每当过滤器包含零时我都会遇到问题,所以我想知道除了使用 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);
【问题讨论】:
-
是的,但我想知道它是如何使用 FFT 实现的
-
我认为你做得对。只是不要为指定输出大小而烦恼。 fft 函数的输出将始终为 u 提供与输入信号相同的大小,因为它实际上实现了 DFT。此外,您可能需要将 ifft 结果除以信号的长度(不确定 MATLAB 是否自动执行此操作)。
-
@Kishore 在使用 FFT 转换过滤器后,一些条目为零,我认为这种方法有缺陷。
-
哦,等等,我认为当数组包含零时您会遇到问题,因为您正在除以零。为此,此链接提供了一些指导:mathworks.in/matlabcentral/newsreader/view_thread/101760
标签: matlab image-processing signal-processing