[数字图像处理]频域滤波(1)--基础与低通滤波器

之前的博文主要介绍了空间域内的滤波器,本文主要从频域的角度进行分析。主要使用傅里叶变换,将空间域的图像转换到频域内,在频域内进行数字图像处理。这部分的内容及其重要,频域内的处理可以解决空间域内无法完成的图像增强。本文首先从数学角度,对图像的频域内的性质进行分析,然后在着重介绍滤波器在频域内的性质。

        1.傅里叶变换与频域

        在之前的文中,我们已经进行过一些基本的图像处理。比如,使用低通滤波可以将图像模糊,也有些许降噪的作用。这些都是在空间域内进行的滤波处理,这个处理主要是依靠卷积来进行计算的。首先,从连续的一维卷积入手,如下所示。


       将上式进行傅里叶变换,可以得到如下结果。


        从这个式子,我们可以得到一个重要的结论。也就是,函数卷积的傅里叶变换所得到的结果,是函数的傅里叶变换的乘积。再将其总结得简单易懂一些,有如下结论。


        在将其扩展到二维的形况下,假设尺寸为MxN的图像,如下关系是成立的。


       其实到这,基本的原理就明了的。我们所看到的图像,均为空间域内的表现形式,我们无法辨识出频域内的图像。要进行频域内的滤波器处理,首先就需要进行傅里叶变换,然后直接进行滤波处理,最后再用反傅里叶变换倒回到空间域内。

       到此,已经可以开始空间域内的滤波处理了。但是,还有一点需要注意的地方。使用某个一维信号来举例子,一维信号的傅里叶变换是以2π为周期的函数。所以,我们常常使用的范围[-π,π]来表示这个信号的傅里叶变换,如下所示。


        这样做的好处是,靠近0的成分就是低频,靠近-π与π的成分就表示高频。而对于图像而言,在Matlab中,我们使用fft2()这个函数来求取图像的傅里叶变换。

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. g = fft2(f);     
        上面这个代码求取的,其实是 范围[0,π]内的傅里叶变换。为了方便理解,下图画出了本行代码所求取的图像的傅里叶变换的范围(右)和与其等效的一维傅里叶变换的范围(左)。


       很显然,这并不是希望的范围,下面这个代码可以求取[0,2π]内的傅里叶变换。

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. P = 2*M;  
  2. Q = 2*N;  
  3. F = fft2(f,P,Q);  
       下图画出了本行代码所求取的图像的傅里叶变换的范围(右)和与其等效的一维傅里叶变换的范围 (左) 。所得到的图像F(u,v)的尺寸为PxQ。


         我们需要对其移动一下,如下图所示,我们需要的是粉色范围的区域。


下面,从数学上分析一下,如何获得这个部分的频谱。对于傅里叶变换,有如下性质。


这个特性称为平移特性,粉色部分的频谱,将带入上式,我们可以得到如下式子。


为次,我们已经得到了粉色范围的频谱。越靠近傅里叶频谱图像中间的成分,代表了低频成分。其Matlab代码如下所示。

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. [M,N] = size(f);  
  2. P = 2*M;  
  3. Q = 2*N;  
  4. fc = zeros(M,N);  
  5.   
  6. for x = 1:1:M  
  7.     for y = 1:1:N  
  8.         fc(x,y) = f(x,y) * (-1)^(x+y);  
  9.     end  
  10. end  
  11.   
  12. F = fft2(fc,P,Q);  

        代码所得到的结果,如下图所示。


        接下来,我们总结一下频域滤波的步骤:

        ①:先将图像做频域内的水平移动,然后求原图像f(x,y)的DFT,得到其图像的傅里叶谱F(u,v)。


        ②:与频域滤波器做乘积,

        ③:求取G(u,v)的IDFT,然后再将图像做频域内的水平移动(移动回去),其结果可能存在寄生的虚数,此时忽略即可。


        ④:这里使用ifft2函数进行IDFT变换,得到的图像的尺寸为PxQ。切取左上角的MxN的图像,就能得到结果了。

        2.低通滤波器

        2.1理想的低通滤波器


       其中,D0表示通带的半径。D(u,v)的计算方式也就是两点间的距离,很简单就能得到。

       使用低通滤波器所得到的结果如下所示。低通滤波器滤除了高频成分,所以使得图像模糊。由于理想低通滤波器的过度特性过于急峻,所以会产生了振铃现象。


         

        2.2巴特沃斯低通滤波器

       同样的,D0表示通带的半径,n表示的是巴特沃斯滤波器的次数。随着次数的增加,振铃现象会越来越明显。

   


       2.3高斯低通滤波器


       D0表示通带的半径。高斯滤波器的过度特性非常平坦,因此是不会产生振铃现象的。

       3.实现代码

<a target=_blank id="L1" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;">   1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;">   2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;">   3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;">   4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;">   5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;">   6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;">   7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;">   8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;">   9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;">  10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;">  11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;">  12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;">  13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;">  14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;">  15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;">  16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;">  17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;">  18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;">  19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;">  20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;">  21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;">  22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;">  23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;">  24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;">  25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;">  26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;">  27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;">  28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;">  29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;">  30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;">  31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;">  32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;">  33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;">  34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;">  35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;">  36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L37" rel="#L37" style="color: rgb(102, 102, 102); text-decoration: none;">  37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L38" rel="#L38" style="color: rgb(102, 102, 102); text-decoration: none;">  38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L39" rel="#L39" style="color: rgb(102, 102, 102); text-decoration: none;">  39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L40" rel="#L40" style="color: rgb(102, 102, 102); text-decoration: none;">  40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L41" rel="#L41" style="color: rgb(102, 102, 102); text-decoration: none;">  41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L42" rel="#L42" style="color: rgb(102, 102, 102); text-decoration: none;">  42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L43" rel="#L43" style="color: rgb(102, 102, 102); text-decoration: none;">  43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L44" rel="#L44" style="color: rgb(102, 102, 102); text-decoration: none;">  44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L45" rel="#L45" style="color: rgb(102, 102, 102); text-decoration: none;">  45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L46" rel="#L46" style="color: rgb(102, 102, 102); text-decoration: none;">  46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L47" rel="#L47" style="color: rgb(102, 102, 102); text-decoration: none;">  47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L48" rel="#L48" style="color: rgb(102, 102, 102); text-decoration: none;">  48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L49" rel="#L49" style="color: rgb(102, 102, 102); text-decoration: none;">  49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L50" rel="#L50" style="color: rgb(102, 102, 102); text-decoration: none;">  50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L51" rel="#L51" style="color: rgb(102, 102, 102); text-decoration: none;">  51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L52" rel="#L52" style="color: rgb(102, 102, 102); text-decoration: none;">  52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L53" rel="#L53" style="color: rgb(102, 102, 102); text-decoration: none;">  53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L54" rel="#L54" style="color: rgb(102, 102, 102); text-decoration: none;">  54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L55" rel="#L55" style="color: rgb(102, 102, 102); text-decoration: none;">  55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L56" rel="#L56" style="color: rgb(102, 102, 102); text-decoration: none;">  56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L57" rel="#L57" style="color: rgb(102, 102, 102); text-decoration: none;">  57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L58" rel="#L58" style="color: rgb(102, 102, 102); text-decoration: none;">  58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L59" rel="#L59" style="color: rgb(102, 102, 102); text-decoration: none;">  59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L60" rel="#L60" style="color: rgb(102, 102, 102); text-decoration: none;">  60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L61" rel="#L61" style="color: rgb(102, 102, 102); text-decoration: none;">  61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L62" rel="#L62" style="color: rgb(102, 102, 102); text-decoration: none;">  62</a>
<a target=_blank id="L63" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L63" rel="#L63" style="color: rgb(102, 102, 102); text-decoration: none;">  63</a>
<a target=_blank id="L64" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L64" rel="#L64" style="color: rgb(102, 102, 102); text-decoration: none;">  64</a>
<a target=_blank id="L65" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L65" rel="#L65" style="color: rgb(102, 102, 102); text-decoration: none;">  65</a>
<a target=_blank id="L66" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L66" rel="#L66" style="color: rgb(102, 102, 102); text-decoration: none;">  66</a>
<a target=_blank id="L67" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L67" rel="#L67" style="color: rgb(102, 102, 102); text-decoration: none;">  67</a>
<a target=_blank id="L68" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L68" rel="#L68" style="color: rgb(102, 102, 102); text-decoration: none;">  68</a>
<a target=_blank id="L69" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L69" rel="#L69" style="color: rgb(102, 102, 102); text-decoration: none;">  69</a>
<a target=_blank id="L70" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L70" rel="#L70" style="color: rgb(102, 102, 102); text-decoration: none;">  70</a>
<a target=_blank id="L71" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L71" rel="#L71" style="color: rgb(102, 102, 102); text-decoration: none;">  71</a>
<a target=_blank id="L72" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L72" rel="#L72" style="color: rgb(102, 102, 102); text-decoration: none;">  72</a>
<a target=_blank id="L73" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L73" rel="#L73" style="color: rgb(102, 102, 102); text-decoration: none;">  73</a>
<a target=_blank id="L74" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L74" rel="#L74" style="color: rgb(102, 102, 102); text-decoration: none;">  74</a>
<a target=_blank id="L75" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L75" rel="#L75" style="color: rgb(102, 102, 102); text-decoration: none;">  75</a>
<a target=_blank id="L76" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L76" rel="#L76" style="color: rgb(102, 102, 102); text-decoration: none;">  76</a>
<a target=_blank id="L77" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L77" rel="#L77" style="color: rgb(102, 102, 102); text-decoration: none;">  77</a>
<a target=_blank id="L78" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L78" rel="#L78" style="color: rgb(102, 102, 102); text-decoration: none;">  78</a>
<a target=_blank id="L79" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L79" rel="#L79" style="color: rgb(102, 102, 102); text-decoration: none;">  79</a>
<a target=_blank id="L80" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L80" rel="#L80" style="color: rgb(102, 102, 102); text-decoration: none;">  80</a>
<a target=_blank id="L81" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L81" rel="#L81" style="color: rgb(102, 102, 102); text-decoration: none;">  81</a>
<a target=_blank id="L82" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L82" rel="#L82" style="color: rgb(102, 102, 102); text-decoration: none;">  82</a>
<a target=_blank id="L83" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L83" rel="#L83" style="color: rgb(102, 102, 102); text-decoration: none;">  83</a>
<a target=_blank id="L84" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L84" rel="#L84" style="color: rgb(102, 102, 102); text-decoration: none;">  84</a>
<a target=_blank id="L85" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L85" rel="#L85" style="color: rgb(102, 102, 102); text-decoration: none;">  85</a>
<a target=_blank id="L86" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L86" rel="#L86" style="color: rgb(102, 102, 102); text-decoration: none;">  86</a>
<a target=_blank id="L87" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L87" rel="#L87" style="color: rgb(102, 102, 102); text-decoration: none;">  87</a>
<a target=_blank id="L88" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L88" rel="#L88" style="color: rgb(102, 102, 102); text-decoration: none;">  88</a>
<a target=_blank id="L89" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L89" rel="#L89" style="color: rgb(102, 102, 102); text-decoration: none;">  89</a>
<a target=_blank id="L90" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L90" rel="#L90" style="color: rgb(102, 102, 102); text-decoration: none;">  90</a>
<a target=_blank id="L91" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L91" rel="#L91" style="color: rgb(102, 102, 102); text-decoration: none;">  91</a>
<a target=_blank id="L92" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L92" rel="#L92" style="color: rgb(102, 102, 102); text-decoration: none;">  92</a>
<a target=_blank id="L93" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L93" rel="#L93" style="color: rgb(102, 102, 102); text-decoration: none;">  93</a>
<a target=_blank id="L94" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L94" rel="#L94" style="color: rgb(102, 102, 102); text-decoration: none;">  94</a>
<a target=_blank id="L95" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L95" rel="#L95" style="color: rgb(102, 102, 102); text-decoration: none;">  95</a>
<a target=_blank id="L96" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L96" rel="#L96" style="color: rgb(102, 102, 102); text-decoration: none;">  96</a>
<a target=_blank id="L97" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L97" rel="#L97" style="color: rgb(102, 102, 102); text-decoration: none;">  97</a>
<a target=_blank id="L98" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L98" rel="#L98" style="color: rgb(102, 102, 102); text-decoration: none;">  98</a>
<a target=_blank id="L99" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L99" rel="#L99" style="color: rgb(102, 102, 102); text-decoration: none;">  99</a>
<a target=_blank id="L100" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L100" rel="#L100" style="color: rgb(102, 102, 102); text-decoration: none;"> 100</a>
           
           
close all ;
clear all ;
%% ---------Butterworth Lowpass Filters (Fre. Domain)------------
f = imread ( 'characters_test_pattern.tif' );
f = mat2gray ( f ,[ 0 255 ]);
[ M , N ] = size ( f );
P = 2 * M ;
Q = 2 * N ;
fc = zeros ( M , N );
for x = 1 : 1 : M
for y = 1 : 1 : N
fc ( x , y ) = f ( x , y ) * ( - 1 )^ ( x + y );
end
end
F = fft2 ( fc , P , Q );
H_1 = zeros ( P , Q );
H_2 = zeros ( P , Q );
for x = ( - P / 2 ): 1 :( P / 2 ) - 1
for y = ( - Q / 2 ): 1 :( Q / 2 ) - 1
D = ( x^ 2 + y^ 2 )^ ( 0.5 );
D_0 = 100 ;
H_1 ( x + ( P / 2 ) + 1 , y + ( Q / 2 ) + 1 ) = 1 / ( 1 + ( D / D_0 )^ 2 );
H_2 ( x + ( P / 2 ) + 1 , y + ( Q / 2 ) + 1 ) = 1 / ( 1 + ( D / D_0 )^ 6 );
end
end
G_1 = H_1 .* F ;
G_2 = H_2 .* F ;
g_1 = real ( ifft2 ( G_1 ));
g_1 = g_1 ( 1 : 1 : M , 1 : 1 : N );
g_2 = real ( ifft2 ( G_2 ));
g_2 = g_2 ( 1 : 1 : M , 1 : 1 : N );
for x = 1 : 1 : M
for y = 1 : 1 : N
g_1 ( x , y ) = g_1 ( x , y ) * ( - 1 )^ ( x + y );
g_2 ( x , y ) = g_2 ( x , y ) * ( - 1 )^ ( x + y );
end
end
%% -----show-------
figure ();
subplot ( 1 , 2 , 1 );
imshow ( f ,[ 0 1 ]);
xlabel ( 'a).Original Image' );
subplot ( 1 , 2 , 2 );
imshow ( log ( 1 + abs ( F )),[ ]);
xlabel ( 'b).Fourier spectrum of a' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( H_1 ,[ 0 1 ]);
xlabel ( 'c)Butterworth Lowpass (D_{0}=100,n=1)' );
subplot ( 1 , 2 , 2 );
h = mesh ( 1 : 20 : P , 1 : 20 : Q , H_1 ( 1 : 20 : P , 1 : 20 : Q ));
set ( h , 'EdgeColor' , 'k' );
axis ([ 0 P 0 Q 0 1 ]);
xlabel ( 'u' ); ylabel ( 'v' );
zlabel ( '|H(u,v)|' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( log ( 1 + abs ( G_1 )),[ ]);
xlabel ( 'd).Result of filtering using c' );
subplot ( 1 , 2 , 2 );
imshow ( g_1 ,[ 0 1 ]);
xlabel ( 'e).Result image' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( H_2 ,[ 0 1 ]);
xlabel ( 'f).Butterworth Lowpass (D_{0}=100,n=3)' );
subplot ( 1 , 2 , 2 );
h = mesh ( 1 : 20 : P , 1 : 20 : Q , H_2 ( 1 : 20 : P , 1 : 20 : Q ));
set ( h , 'EdgeColor' , 'k' );
axis ([ 0 P 0 Q 0 1 ]);
xlabel ( 'u' ); ylabel ( 'v' );
zlabel ( '|H(u,v)|' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( log ( 1 + abs ( G_2 )),[ ]);
xlabel ( 'g).Result of filtering using e' );
subplot ( 1 , 2 , 2 );
imshow ( g_2 ,[ 0 1 ]);
xlabel ( 'h).Result image' );
 来自CODE的代码片
Butterworth_Lowpass_Filters.m
<a target=_blank id="L1" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;">   1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;">   2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;">   3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;">   4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;">   5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;">   6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;">   7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;">   8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;">   9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;">  10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;">  11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;">  12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;">  13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;">  14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;">  15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;">  16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;">  17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;">  18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;">  19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;">  20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;">  21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;">  22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;">  23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;">  24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;">  25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;">  26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;">  27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;">  28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;">  29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;">  30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;">  31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;">  32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;">  33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;">  34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;">  35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;">  36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L37" rel="#L37" style="color: rgb(102, 102, 102); text-decoration: none;">  37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L38" rel="#L38" style="color: rgb(102, 102, 102); text-decoration: none;">  38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L39" rel="#L39" style="color: rgb(102, 102, 102); text-decoration: none;">  39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L40" rel="#L40" style="color: rgb(102, 102, 102); text-decoration: none;">  40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L41" rel="#L41" style="color: rgb(102, 102, 102); text-decoration: none;">  41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L42" rel="#L42" style="color: rgb(102, 102, 102); text-decoration: none;">  42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L43" rel="#L43" style="color: rgb(102, 102, 102); text-decoration: none;">  43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L44" rel="#L44" style="color: rgb(102, 102, 102); text-decoration: none;">  44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L45" rel="#L45" style="color: rgb(102, 102, 102); text-decoration: none;">  45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L46" rel="#L46" style="color: rgb(102, 102, 102); text-decoration: none;">  46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L47" rel="#L47" style="color: rgb(102, 102, 102); text-decoration: none;">  47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L48" rel="#L48" style="color: rgb(102, 102, 102); text-decoration: none;">  48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L49" rel="#L49" style="color: rgb(102, 102, 102); text-decoration: none;">  49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L50" rel="#L50" style="color: rgb(102, 102, 102); text-decoration: none;">  50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L51" rel="#L51" style="color: rgb(102, 102, 102); text-decoration: none;">  51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L52" rel="#L52" style="color: rgb(102, 102, 102); text-decoration: none;">  52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L53" rel="#L53" style="color: rgb(102, 102, 102); text-decoration: none;">  53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L54" rel="#L54" style="color: rgb(102, 102, 102); text-decoration: none;">  54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L55" rel="#L55" style="color: rgb(102, 102, 102); text-decoration: none;">  55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L56" rel="#L56" style="color: rgb(102, 102, 102); text-decoration: none;">  56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L57" rel="#L57" style="color: rgb(102, 102, 102); text-decoration: none;">  57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L58" rel="#L58" style="color: rgb(102, 102, 102); text-decoration: none;">  58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L59" rel="#L59" style="color: rgb(102, 102, 102); text-decoration: none;">  59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L60" rel="#L60" style="color: rgb(102, 102, 102); text-decoration: none;">  60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L61" rel="#L61" style="color: rgb(102, 102, 102); text-decoration: none;">  61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L62" rel="#L62" style="color: rgb(102, 102, 102); text-decoration: none;">  62</a>
<a target=_blank id="L63" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L63" rel="#L63" style="color: rgb(102, 102, 102); text-decoration: none;">  63</a>
<a target=_blank id="L64" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L64" rel="#L64" style="color: rgb(102, 102, 102); text-decoration: none;">  64</a>
<a target=_blank id="L65" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L65" rel="#L65" style="color: rgb(102, 102, 102); text-decoration: none;">  65</a>
<a target=_blank id="L66" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L66" rel="#L66" style="color: rgb(102, 102, 102); text-decoration: none;">  66</a>
<a target=_blank id="L67" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L67" rel="#L67" style="color: rgb(102, 102, 102); text-decoration: none;">  67</a>
<a target=_blank id="L68" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L68" rel="#L68" style="color: rgb(102, 102, 102); text-decoration: none;">  68</a>
<a target=_blank id="L69" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L69" rel="#L69" style="color: rgb(102, 102, 102); text-decoration: none;">  69</a>
<a target=_blank id="L70" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L70" rel="#L70" style="color: rgb(102, 102, 102); text-decoration: none;">  70</a>
<a target=_blank id="L71" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L71" rel="#L71" style="color: rgb(102, 102, 102); text-decoration: none;">  71</a>
<a target=_blank id="L72" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L72" rel="#L72" style="color: rgb(102, 102, 102); text-decoration: none;">  72</a>
<a target=_blank id="L73" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L73" rel="#L73" style="color: rgb(102, 102, 102); text-decoration: none;">  73</a>
<a target=_blank id="L74" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L74" rel="#L74" style="color: rgb(102, 102, 102); text-decoration: none;">  74</a>
<a target=_blank id="L75" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L75" rel="#L75" style="color: rgb(102, 102, 102); text-decoration: none;">  75</a>
<a target=_blank id="L76" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L76" rel="#L76" style="color: rgb(102, 102, 102); text-decoration: none;">  76</a>
<a target=_blank id="L77" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L77" rel="#L77" style="color: rgb(102, 102, 102); text-decoration: none;">  77</a>
<a target=_blank id="L78" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L78" rel="#L78" style="color: rgb(102, 102, 102); text-decoration: none;">  78</a>
<a target=_blank id="L79" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L79" rel="#L79" style="color: rgb(102, 102, 102); text-decoration: none;">  79</a>
<a target=_blank id="L80" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L80" rel="#L80" style="color: rgb(102, 102, 102); text-decoration: none;">  80</a>
<a target=_blank id="L81" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L81" rel="#L81" style="color: rgb(102, 102, 102); text-decoration: none;">  81</a>
<a target=_blank id="L82" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L82" rel="#L82" style="color: rgb(102, 102, 102); text-decoration: none;">  82</a>
<a target=_blank id="L83" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L83" rel="#L83" style="color: rgb(102, 102, 102); text-decoration: none;">  83</a>
<a target=_blank id="L84" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L84" rel="#L84" style="color: rgb(102, 102, 102); text-decoration: none;">  84</a>
<a target=_blank id="L85" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L85" rel="#L85" style="color: rgb(102, 102, 102); text-decoration: none;">  85</a>
<a target=_blank id="L86" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L86" rel="#L86" style="color: rgb(102, 102, 102); text-decoration: none;">  86</a>
<a target=_blank id="L87" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L87" rel="#L87" style="color: rgb(102, 102, 102); text-decoration: none;">  87</a>
<a target=_blank id="L88" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L88" rel="#L88" style="color: rgb(102, 102, 102); text-decoration: none;">  88</a>
<a target=_blank id="L89" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L89" rel="#L89" style="color: rgb(102, 102, 102); text-decoration: none;">  89</a>
<a target=_blank id="L90" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L90" rel="#L90" style="color: rgb(102, 102, 102); text-decoration: none;">  90</a>
<a target=_blank id="L91" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L91" rel="#L91" style="color: rgb(102, 102, 102); text-decoration: none;">  91</a>
<a target=_blank id="L92" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L92" rel="#L92" style="color: rgb(102, 102, 102); text-decoration: none;">  92</a>
<a target=_blank id="L93" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L93" rel="#L93" style="color: rgb(102, 102, 102); text-decoration: none;">  93</a>
<a target=_blank id="L94" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L94" rel="#L94" style="color: rgb(102, 102, 102); text-decoration: none;">  94</a>
<a target=_blank id="L95" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L95" rel="#L95" style="color: rgb(102, 102, 102); text-decoration: none;">  95</a>
<a target=_blank id="L96" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L96" rel="#L96" style="color: rgb(102, 102, 102); text-decoration: none;">  96</a>
<a target=_blank id="L97" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L97" rel="#L97" style="color: rgb(102, 102, 102); text-decoration: none;">  97</a>
<a target=_blank id="L98" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L98" rel="#L98" style="color: rgb(102, 102, 102); text-decoration: none;">  98</a>
<a target=_blank id="L99" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L99" rel="#L99" style="color: rgb(102, 102, 102); text-decoration: none;">  99</a>
<a target=_blank id="L100" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L100" rel="#L100" style="color: rgb(102, 102, 102); text-decoration: none;"> 100</a>
<a target=_blank id="L101" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L101" rel="#L101" style="color: rgb(102, 102, 102); text-decoration: none;"> 101</a>
<a target=_blank id="L102" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L102" rel="#L102" style="color: rgb(102, 102, 102); text-decoration: none;"> 102</a>
<a target=_blank id="L103" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L103" rel="#L103" style="color: rgb(102, 102, 102); text-decoration: none;"> 103</a>
           
           
close all ;
clear all ;
clc ;
%% ---------Gaussian Lowpass Filters (Fre. Domain)------------
f = imread ( 'characters_test_pattern.tif' );
f = mat2gray ( f ,[ 0 255 ]);
[ M , N ] = size ( f );
P = 2 * M ;
Q = 2 * N ;
fc = zeros ( M , N );
for x = 1 : 1 : M
for y = 1 : 1 : N
fc ( x , y ) = f ( x , y ) * ( - 1 )^ ( x + y );
end
end
F = fft2 ( fc , P , Q );
H_1 = zeros ( P , Q );
H_2 = zeros ( P , Q );
for x = ( - P / 2 ): 1 :( P / 2 ) - 1
for y = ( - Q / 2 ): 1 :( Q / 2 ) - 1
D = ( x^ 2 + y^ 2 )^ ( 0.5 );
D_0 = 60 ;
H_1 ( x + ( P / 2 ) + 1 , y + ( Q / 2 ) + 1 ) = exp ( - ( D * D ) / ( 2 * D_0 * D_0 ));
D_0 = 160 ;
H_2 ( x + ( P / 2 ) + 1 , y + ( Q / 2 ) + 1 ) = exp ( - ( D * D ) / ( 2 * D_0 * D_0 ));
end
end
G_1 = H_1 .* F ;
G_2 = H_2 .* F ;
g_1 = real ( ifft2 ( G_1 ));
g_1 = g_1 ( 1 : 1 : M , 1 : 1 : N );
g_2 = real ( ifft2 ( G_2 ));
g_2 = g_2 ( 1 : 1 : M , 1 : 1 : N );
for x = 1 : 1 : M
for y = 1 : 1 : N
g_1 ( x , y ) = g_1 ( x , y ) * ( - 1 )^ ( x + y );
g_2 ( x , y ) = g_2 ( x , y ) * ( - 1 )^ ( x + y );
end
end
%% -----show-------
close all ;
figure ();
subplot ( 1 , 2 , 1 );
imshow ( f ,[ 0 1 ]);
xlabel ( 'a).Original Image' );
subplot ( 1 , 2 , 2 );
imshow ( log ( 1 + abs ( F )),[ ]);
xlabel ( 'b).Fourier spectrum of a' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( H_1 ,[ 0 1 ]);
xlabel ( 'c)Gaussian Lowpass (D_{0}=60)' );
subplot ( 1 , 2 , 2 );
h = mesh ( 1 : 20 : P , 1 : 20 : Q , H_1 ( 1 : 20 : P , 1 : 20 : Q ));
set ( h , 'EdgeColor' , 'k' );
axis ([ 0 P 0 Q 0 1 ]);
xlabel ( 'u' ); ylabel ( 'v' );
zlabel ( '|H(u,v)|' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( log ( 1 + abs ( G_1 )),[ ]);
xlabel ( 'd).Result of filtering using c' );
subplot ( 1 , 2 , 2 );
imshow ( g_1 ,[ 0 1 ]);
xlabel ( 'e).Result image' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( H_2 ,[ 0 1 ]);
xlabel ( 'f).Gaussian Lowpass (D_{0}=160)' );
subplot ( 1 , 2 , 2 );
h = mesh ( 1 : 20 : P , 1 : 20 : Q , H_2 ( 1 : 20 : P , 1 : 20 : Q ));
set ( h , 'EdgeColor' , 'k' );
axis ([ 0 P 0 Q 0 1 ]);
xlabel ( 'u' ); ylabel ( 'v' );
zlabel ( '|H(u,v)|' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( log ( 1 + abs ( G_2 )),[ ]);
xlabel ( 'g).Result of filtering using e' );
subplot ( 1 , 2 , 2 );
imshow ( g_2 ,[ 0 1 ]);
xlabel ( 'h).Result image' );
 来自CODE的代码片
Gaussian_Lowpass_Filters.m
<a target=_blank id="L1" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;"> 24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;"> 25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;"> 26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;"> 27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;"> 28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;"> 29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;"> 30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;"> 31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;"> 32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;"> 33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;"> 34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;"> 35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;"> 36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L37" rel="#L37" style="color: rgb(102, 102, 102); text-decoration: none;"> 37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L38" rel="#L38" style="color: rgb(102, 102, 102); text-decoration: none;"> 38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L39" rel="#L39" style="color: rgb(102, 102, 102); text-decoration: none;"> 39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L40" rel="#L40" style="color: rgb(102, 102, 102); text-decoration: none;"> 40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L41" rel="#L41" style="color: rgb(102, 102, 102); text-decoration: none;"> 41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L42" rel="#L42" style="color: rgb(102, 102, 102); text-decoration: none;"> 42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L43" rel="#L43" style="color: rgb(102, 102, 102); text-decoration: none;"> 43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L44" rel="#L44" style="color: rgb(102, 102, 102); text-decoration: none;"> 44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L45" rel="#L45" style="color: rgb(102, 102, 102); text-decoration: none;"> 45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L46" rel="#L46" style="color: rgb(102, 102, 102); text-decoration: none;"> 46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L47" rel="#L47" style="color: rgb(102, 102, 102); text-decoration: none;"> 47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L48" rel="#L48" style="color: rgb(102, 102, 102); text-decoration: none;"> 48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L49" rel="#L49" style="color: rgb(102, 102, 102); text-decoration: none;"> 49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L50" rel="#L50" style="color: rgb(102, 102, 102); text-decoration: none;"> 50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L51" rel="#L51" style="color: rgb(102, 102, 102); text-decoration: none;"> 51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L52" rel="#L52" style="color: rgb(102, 102, 102); text-decoration: none;"> 52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L53" rel="#L53" style="color: rgb(102, 102, 102); text-decoration: none;"> 53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L54" rel="#L54" style="color: rgb(102, 102, 102); text-decoration: none;"> 54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L55" rel="#L55" style="color: rgb(102, 102, 102); text-decoration: none;"> 55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L56" rel="#L56" style="color: rgb(102, 102, 102); text-decoration: none;"> 56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L57" rel="#L57" style="color: rgb(102, 102, 102); text-decoration: none;"> 57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L58" rel="#L58" style="color: rgb(102, 102, 102); text-decoration: none;"> 58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L59" rel="#L59" style="color: rgb(102, 102, 102); text-decoration: none;"> 59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L60" rel="#L60" style="color: rgb(102, 102, 102); text-decoration: none;"> 60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L61" rel="#L61" style="color: rgb(102, 102, 102); text-decoration: none;"> 61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L62" rel="#L62" style="color: rgb(102, 102, 102); text-decoration: none;"> 62</a>
<a target=_blank id="L63" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L63" rel="#L63" style="color: rgb(102, 102, 102); text-decoration: none;"> 63</a>
<a target=_blank id="L64" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L64" rel="#L64" style="color: rgb(102, 102, 102); text-decoration: none;"> 64</a>
<a target=_blank id="L65" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L65" rel="#L65" style="color: rgb(102, 102, 102); text-decoration: none;"> 65</a>
<a target=_blank id="L66" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L66" rel="#L66" style="color: rgb(102, 102, 102); text-decoration: none;"> 66</a>
<a target=_blank id="L67" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L67" rel="#L67" style="color: rgb(102, 102, 102); text-decoration: none;"> 67</a>
<a target=_blank id="L68" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L68" rel="#L68" style="color: rgb(102, 102, 102); text-decoration: none;"> 68</a>
<a target=_blank id="L69" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L69" rel="#L69" style="color: rgb(102, 102, 102); text-decoration: none;"> 69</a>
<a target=_blank id="L70" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L70" rel="#L70" style="color: rgb(102, 102, 102); text-decoration: none;"> 70</a>
<a target=_blank id="L71" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L71" rel="#L71" style="color: rgb(102, 102, 102); text-decoration: none;"> 71</a>
<a target=_blank id="L72" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L72" rel="#L72" style="color: rgb(102, 102, 102); text-decoration: none;"> 72</a>
<a target=_blank id="L73" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L73" rel="#L73" style="color: rgb(102, 102, 102); text-decoration: none;"> 73</a>
<a target=_blank id="L74" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L74" rel="#L74" style="color: rgb(102, 102, 102); text-decoration: none;"> 74</a>
<a target=_blank id="L75" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L75" rel="#L75" style="color: rgb(102, 102, 102); text-decoration: none;"> 75</a>
<a target=_blank id="L76" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L76" rel="#L76" style="color: rgb(102, 102, 102); text-decoration: none;"> 76</a>
<a target=_blank id="L77" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L77" rel="#L77" style="color: rgb(102, 102, 102); text-decoration: none;"> 77</a>
<a target=_blank id="L78" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L78" rel="#L78" style="color: rgb(102, 102, 102); text-decoration: none;"> 78</a>
<a target=_blank id="L79" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L79" rel="#L79" style="color: rgb(102, 102, 102); text-decoration: none;"> 79</a>
<a target=_blank id="L80" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L80" rel="#L80" style="color: rgb(102, 102, 102); text-decoration: none;"> 80</a>
<a target=_blank id="L81" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L81" rel="#L81" style="color: rgb(102, 102, 102); text-decoration: none;"> 81</a>
<a target=_blank id="L82" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L82" rel="#L82" style="color: rgb(102, 102, 102); text-decoration: none;"> 82</a>
<a target=_blank id="L83" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L83" rel="#L83" style="color: rgb(102, 102, 102); text-decoration: none;"> 83</a>
<a target=_blank id="L84" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L84" rel="#L84" style="color: rgb(102, 102, 102); text-decoration: none;"> 84</a>
<a target=_blank id="L85" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L85" rel="#L85" style="color: rgb(102, 102, 102); text-decoration: none;"> 85</a>
<a target=_blank id="L86" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L86" rel="#L86" style="color: rgb(102, 102, 102); text-decoration: none;"> 86</a>
<a target=_blank id="L87" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L87" rel="#L87" style="color: rgb(102, 102, 102); text-decoration: none;"> 87</a>
<a target=_blank id="L88" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L88" rel="#L88" style="color: rgb(102, 102, 102); text-decoration: none;"> 88</a>
<a target=_blank id="L89" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L89" rel="#L89" style="color: rgb(102, 102, 102); text-decoration: none;"> 89</a>
<a target=_blank id="L90" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L90" rel="#L90" style="color: rgb(102, 102, 102); text-decoration: none;"> 90</a>
<a target=_blank id="L91" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L91" rel="#L91" style="color: rgb(102, 102, 102); text-decoration: none;"> 91</a>
<a target=_blank id="L92" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L92" rel="#L92" style="color: rgb(102, 102, 102); text-decoration: none;"> 92</a>
<a target=_blank id="L93" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L93" rel="#L93" style="color: rgb(102, 102, 102); text-decoration: none;"> 93</a>
<a target=_blank id="L94" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L94" rel="#L94" style="color: rgb(102, 102, 102); text-decoration: none;"> 94</a>
<a target=_blank id="L95" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L95" rel="#L95" style="color: rgb(102, 102, 102); text-decoration: none;"> 95</a>
<a target=_blank id="L96" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L96" rel="#L96" style="color: rgb(102, 102, 102); text-decoration: none;"> 96</a>
<a target=_blank id="L97" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L97" rel="#L97" style="color: rgb(102, 102, 102); text-decoration: none;"> 97</a>
<a target=_blank id="L98" href="http://blog.csdn.net/zhoufan900428/article/details/17194289#L98" rel="#L98" style="color: rgb(102, 102, 102); text-decoration: none;"> 98</a>
           
           
close all ;
clear all ;
%% ---------Ideal Lowpass Filters (Fre. Domain)------------
f = imread ( 'characters_test_pattern.tif' );
f = mat2gray ( f ,[ 0 255 ]);
[ M , N ] = size ( f );
P = 2 * M ;
Q = 2 * N ;
fc = zeros ( M , N );
for x = 1 : 1 : M
for y = 1 : 1 : N
fc ( x , y ) = f ( x , y ) * ( - 1 )^ ( x + y );
end
end
F = fft2 ( fc , P , Q );
H_1 = zeros ( P , Q );
H_2 = zeros ( P , Q );
for x = ( - P / 2 ): 1 :( P / 2 ) - 1
for y = ( - Q / 2 ): 1 :( Q / 2 ) - 1
D = ( x^ 2 + y^ 2 )^ ( 0.5 );
if ( D < = 60 ) H_1 ( x + ( P / 2 ) + 1 , y + ( Q / 2 ) + 1 ) = 1 ; end
if ( D < = 160 ) H_2 ( x + ( P / 2 ) + 1 , y + ( Q / 2 ) + 1 ) = 1 ; end
end
end
G_1 = H_1 .* F ;
G_2 = H_2 .* F ;
g_1 = real ( ifft2 ( G_1 ));
g_1 = g_1 ( 1 : 1 : M , 1 : 1 : N );
g_2 = real ( ifft2 ( G_2 ));
g_2 = g_2 ( 1 : 1 : M , 1 : 1 : N );
for x = 1 : 1 : M
for y = 1 : 1 : N
g_1 ( x , y ) = g_1 ( x , y ) * ( - 1 )^ ( x + y );
g_2 ( x , y ) = g_2 ( x , y ) * ( - 1 )^ ( x + y );
end
end
%% -----show-------
figure ();
subplot ( 1 , 2 , 1 );
imshow ( f ,[ 0 1 ]);
xlabel ( 'a).Original Image' );
subplot ( 1 , 2 , 2 );
imshow ( log ( 1 + abs ( F )),[ ]);
xlabel ( 'b).Fourier spectrum of a' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( H_1 ,[ 0 1 ]);
xlabel ( 'c).Ideal Lowpass filter(D=60)' );
subplot ( 1 , 2 , 2 );
h = mesh ( 1 : 20 : P , 1 : 20 : Q , H_1 ( 1 : 20 : P , 1 : 20 : Q ));
set ( h , 'EdgeColor' , 'k' );
axis ([ 0 P 0 Q 0 1 ]);
xlabel ( 'u' ); ylabel ( 'v' );
zlabel ( '|H(u,v)|' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( log ( 1 + abs ( G_1 )),[ ]);
xlabel ( 'd).Result of filtering using c' );
subplot ( 1 , 2 , 2 );
imshow ( g_1 ,[ 0 1 ]);
xlabel ( 'e).Result image' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( H_2 ,[ 0 1 ]);
xlabel ( 'f).Ideal Lowpass filter(D=160)' );
subplot ( 1 , 2 , 2 );
h = mesh ( 1 : 20 : P , 1 : 20 : Q , H_2 ( 1 : 20 : P , 1 : 20 : Q ));
set ( h , 'EdgeColor' , 'k' );
axis ([ 0 P 0 Q 0 1 ]);
xlabel ( 'u' ); ylabel ( 'v' );
zlabel ( '|H(u,v)|' );
figure ();
subplot ( 1 , 2 , 1 );
imshow ( log ( 1 + abs ( G_2 )),[ ]);
xlabel ( 'g).Result of filtering using e' );
subplot ( 1 , 2 , 2 );
imshow ( g_2 ,[ 0 1 ]);
xlabel ( 'h).Result image' );
 来自CODE的代码片
Ideal_Lowpass.m

      原文发于博客:http://blog.csdn.net/thnh169/ 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值