实验要求:

Objective:

To further understand the well-known algorithm Fast Fourier Transform (FFT) and verify its effectiveness to calculate the discrete Fourier transform (DFT).

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

The purpose of this project is to develop a 2-D FFT program “package” that will be used in several other projects that follow. Your implementation must have the capabilities to:

(a) Multiply the input image by (-1)x+y to center the transform for filtering.

(b) Multiply the resulting (complex) array by a real function (in the sense that the the real coefficients multiply both the real and imaginary parts of the transforms). Recall that multiplication of two images is done on pairs of corresponding elements.

(c) Compute the inverse Fourier transform.

(d) Multiply the result by (-1)x+y and take the real part.

(e) Compute the spectrum.

Basically, this project implements Fig. 4.5. If you are using MATLAB, then your Fourier transform program will not be limited to images whose size are integer powers of 2. If you are implementing the program yourself, then the FFT routine you are using may be limited to integer powers of 2. In this case, you may need to zoom or shrink an image to the proper size by using the program you developed in Project 02-04.

An approximation: To simplify this and the following projects (with the exception of Project 04-05), you may ignore image padding (Section 4.6.3). Although your results will not be strictly correct, significant simplifications will be gained not only in image sizes, but also in the need for cropping the final result. The principles will not be affected by this approximation.

实验要求我们编写程序实现2维图像的快速傅里叶变换,并运用于频率域滤波。

简要介绍一下频率域滤波的步骤:

  1. 给定一幅大小为M*N的输入图像f(x,y),计算得到填充参数P和Q。通常,取P=2M,Q=2N;
  2. 添加必要数量的0,形成大小为P*Q的填充后的图像fp(x,y);
  3. 用(-1)^(x+y)乘以fp(x,y),将图像移到其傅里叶变换的中心处;
  4. 计算(3)中的图像DFT,得到F(u,v);
  5. 生成一个实的、对称的滤波器函数H(u,v),其大小与fp(x,y)相同,为P*Q,中心在(P/2, Q/2)。用阵列相乘形成乘积G(u,v);
  6. 计算(5)中结果的逆DFT,取出实部,得到gp(x,y);
  7. 从gp(x,y)的左上象限提取M*N的图像,得到最终处理结果g(x,y)。

上程序:

%%
close all;
clc;
clear all; %%
% 读取图像
img = imread('gray_image.jpg');
figure(1)
imshow(img);
title('original A'); % 得到填充参数P和Q
[M, N] = size(img);
P = 2 * M;
Q = 2 * N; img = double(img);
% 添加必要数量的0
img_fp = zeros(P, Q);
img_fp(1:M, 1:N) = img(1:M, 1:N); figure(2);
imshow(img_fp, []);
title('image B'); % 用(-1)^(x+y)乘以图像的结果
for x = 1:P
for y = 1:Q
img_fp(x, y) = img_fp(x, y) .* (-1)^(x+y);
end
end % figure(3);
% imshow(img_fp, []);
% title('image C'); % 对图像做快速傅里叶变换
img_Fp = fft2(img_fp); % figure(4);
% imshow(img_Fp, []);
% title('image D'); % H = ones(P, Q);
% H(P/2, Q/2) = 0; % H = zeros(P, Q);
% H(P/2, Q/2) = 1;
% H(P/2 - 1, Q/2 - 1) = 1; r = 30;
H = ones(P, Q);
for x = 1:P
for y = 1:Q
d = sqrt((x-M)^2 + (y-N)^2);
if d > r
H(x, y) = 0;
else
H(x, y) = 1;
end % if x == P/2 && y == Q/2
% H(x, y) = 1;
% else
% H(x, y) = 1;
% end
end
end figure(5);
imshow(H, []);
title('image E'); img_G = img_Fp .* H; % figure(6);
% imshow(img_G, []);
% title('image F'); img_g = ifft2(img_G);
img_g = real(img_g); for x = 1:P
for y = 1:Q
img_g(x, y) = img_g(x, y) .* (-1)^(x+y);
end
end % figure(7);
% imshow(img_g, []);
% title('image G'); img_o = img_g(1:M, 1:N); figure(8);
imshow(img_o, []);
title('result H'); imwrite(img_o, 'result.jpg');

实验结果:



上图是原图像;



上图是步骤1和2,扩展后的图像fp(x,y);



上图是滤波器函数H(u,v),中心一个圆内为1,圆外都是0,表示一个低通滤波器;



上图是逆DFT计算得到的gp(x,y);



上图为最终的结果,从gp(x,y)提取出的g(x,y)图像;

明显得,可以发现,低通滤波器使原图像变得模糊了。

数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform 标签: 图像处理MATLAB数字图像处理的更多相关文章

  1. 数字图像处理实验(总计23个)汇总 标签: 图像处理MATLAB 2017-05-31 10:30 175人阅读 评论(0)

    以下这些实验中的代码全部是我自己编写调试通过的,到此,最后进行一下汇总. 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Half ...

  2. 数字图像处理实验(12):PROJECT 05-03,Periodic Noise Reduction Using a Notch Filter 标签: 图像处理MATLAB 2017-0

    实验要求: Objective: To understand the principle of the notch filter and its periodic noise reducing abi ...

  3. 【遥感数字图像处理实验】Erdas版详细图文实验教程(8实验全)

    @ 目录 1. 专栏简介 2. 专栏地址 3. 专栏目录 1. 专栏简介 遥感数字图像的处理,是对遥感数字图像的计算机处理.与工业和医学数字图像不同,遥感数字图像类型更为多样,内容更为复杂.因此,遥感 ...

  4. 移植u-boot.2012.04.01

    /*************************************************** *u-boot版本:u-boot2012.04.01 *gcc版本:arm-linux-gcc ...

  5. MATLAB数字图像处理(二)图像增强

    1         图像增强 1.1            直方图均衡化 对于灰度图像,可以使用直方图均衡化的方法使得原图像的灰度直方图修正为均匀的直方图. 代码如下: I2=histeq(I1); ...

  6. ok6410 u-boot-2012.04.01移植六完善MLC NAND支持

    继ok6410 u-boot-2012.04.01移植四.五后,开发板基本已支持MLC NAND,支持DM9000.但是通过NAND命令更新u-boot到NAND,还存在问题,需要根据u-boot的n ...

  7. ok6410 u-boot-2012.04.01移植七完善u-boot移植(u-boot移植结束)

    继ok6410 u-boot-2012.04.01移植六后,开发板已支持MLC NAND.DM9000等.但还需要完善比如环境变量.mtdpart分区.裁剪.制作补丁等.下面的工作就是完善移植的u-b ...

  8. ok6410 u-boot-2012.04.01移植五支持DM9000

    继ok6410 u-boot-2012.04.01移植四后,开发板基本已支持MLC NAND,但还有一些细节地方修改,这节增加DM9000支持,通过网卡tftp程序到内存,接着通过NAND命令写到NA ...

  9. ok6410 u-boot-2012.04.01移植二修改源码支持单板

    继ok6410 u-boot-2012.04.01移植一后修改代码,对ok6410单板初始化,主要包括时钟.串口.NAND.DDR等初始化.这些工作在以前的裸板程序都写了,直接拿来用.我觉得先写裸板程 ...

随机推荐

  1. JVM_总结_01_JDK的安装

    一.前言 本文主要简要介绍下JDK的安装 二.下载 1.JDK下载地址 前往官方网站下载JDK jdk8官网下载 2.JDK下载 如下图 下载完之后得到安装软件,如下图 三.安装 双击运行安装软件,即 ...

  2. ACM提交,C++,G++,C,GCC的区别

    今天做了一道水题,POJ-1004,水题一个,12个double类型的数求平均数 但是, #include <iostream> #include <cstdio> using ...

  3. 进程、线程、ThreadLlocal

    1.线程是最小的执行单位,而进程中至少一个线程组:如果调度进程和线程,完全由操作系统决定,程序自己不能决定什么时候执行,执行多长时间 Unix/Linux操作系统提供了一个fork()系统调用,它非常 ...

  4. 搭建了一个Apache+Php+MySQL的服务器。要如何通过Apache发布网站使得其他的电脑可以通过局域网访问?

         源址: 1.网站的代码放在文件夹“www”下: 2.配置apache允许他人访问网站:在wamp/apache/apache版本/conf的httpd.conf文件修改代码如下: Optio ...

  5. 2017-2018-1 20179215《Linux内核原理与分析》第十周作业

    第17章 设备与模块 一.设备类型  除了以上3种典型的设备之外,其实Linux中还有一些其他的设备类型,其中见的较多的应该算是"伪设备".所谓"伪设备",其实 ...

  6. Spark入门实战系列

    转自:http://www.cnblogs.com/shishanyuan/p/4699644.html 这一两年Spark技术很火,自己也凑热闹,反复的试验.研究,有痛苦万分也有欣喜若狂,抽空把这些 ...

  7. Laser

    Petya is the most responsible worker in the Research Institute. So he was asked to make a very impor ...

  8. 使用virtualenv搭建python3的环境

    转:http://blog.csdn.net/liuchunming033/article/details/46008301 转:http://www.jb51.net/article/85527.h ...

  9. 使用Jersey和Jetty开发RESTful Web service

    Jersey RESTful 框架是开源的RESTful框架, 实现了JAX-RS (JSR 311 & JSR 339) 规范,是JAX-RS的参考实现,并且提供了更多的特性和工具,简化了R ...

  10. 机器学习:线性回归法(Linear Regression)

    # 注:使用线性回归算法的前提是,假设数据存在线性关系,如果最后求得的准确度R < 0,则说明很可能数据间不存在任何线性关系(也可能是算法中间出现错误),此时就要检查算法或者考虑使用其它算法: ...