在MATLAB中对图像进行低通滤波?

时间:2015-11-11 21:34:30

标签: matlab image-processing fft

我正在尝试编写一个接收图像和频率的MATLAB函数,对该图像执行低通滤波(仅保持低于提供频率的频率),并返回新图像。

我该怎么做呢?现在我有以下内容:

<?php // verify that id+1 exist 
$verif_page_next = $planning_id +1;

$req = mysql_query("SELECT id FROM planning WHERE id = '" . $verif_page_next . "'") 
or exit(mysql_error());
if (mysql_num_rows($req) == 1) {
     $next_page =  $verif_page_next ;
}

// we start the first id 
else {
     $next_page =  1 ;
}


?>

但是,我的输出图像显示为蓝色,没有任何意义。现在我的代码的最后两行(涉及修改newImage的代码)完成了将颜色缩放到正确的值。

我做错了什么?另外,我很惊讶MATLAB似乎没有自动执行此功能的功能。

1 个答案:

答案 0 :(得分:3)

当您只将一个象限归零时,您不会保留2D fft的对称性。 DC位于索引1,奈奎斯特位于索引size(image)/2+1,因此您需要对奈奎斯特进行免费更改。

%generate signal
A=rand(8,8)
[m,n]=size(A)

% FFT
A_fft = fft2(A)
%zero out a symmetric region of frequencies 
A_fft((m/2+1) + (-2:2) , : ) = 0
A_fft( :  , (n/2+1) + (-2:2) ) = 0

% inverse FFT
A_mod = ifft2(A_fft)

%observe that DC is preserved, signal is still real
mean(A(:))
mean(A_mod(:))