实验要求:

Objective:

To know how to implement correlation of 2 functions in the frequency domain and, using the fast algorithms.

Main requirements:

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

Instruction manual:

Download Figs. 4.41(a) and (b) and duplicate Example 4.11 to obtain Fig. 4.41(e). Give the (x,y) coordinates of the location of the maximum value in the 2D correlation function. There is no need to plot the profile in Fig. 4.41(f).

实验只是要求给出二维相关函数中最大值位置的(x,y)坐标,没有必要绘制图中的轮廓。

程序实现步骤:

1、将两幅图像的大小都拓展298×298;

2、两幅图像的每个像素都乘以(-1)^(x+y),使其在频域位于中心位置;

3、做傅里叶变换,转换到频域;

4、在频域两幅图像,一个与另一个的共轭相乘计算相关函数;

5、作傅里叶逆变换转换回空间域;

6、乘以(-1)^(x+y),得到最终结果。

要求使用的两幅图:

Figs. 4.41(a):

Figs. 4.41(b):

实验代码:

% Correlation in the Frequency Domain
close all;
clc;
clear all; %
img_f1 = imread('Fig4.41(a).jpg');
img_f2 = imread('Fig4.41(b).jpg'); [M1, N1] = size(img_f1);
[M2, N2] = size(img_f2); P = 298;
Q = 298;
img_fp1 = zeros(P, Q);
img_fp2 = zeros(P, Q);
img_fp1(1:M1, 1:N1) = img_f1(1:M1, 1:N1);
img_fp2(1:M2, 1:N2) = img_f2(1:M2, 1:N2); for x = 1:P
for y = 1:Q
img_fp1(x, y) = img_fp1(x, y) .* (-1)^(x+y);
img_fp2(x, y) = img_fp2(x, y) .* (-1)^(x+y);
end
end % 傅里叶变换
img_Fp1 = fft2(img_fp1);
img_Fp2 = fft2(img_fp2); % 求共轭
img_Fp = img_Fp2 .* conj(img_Fp1); % 傅里叶变换
img_fp = ifft2(img_Fp); % 乘以(-1)^(x+y)
for x = 1:P
for y = 1:Q
img_fp(x, y) = img_fp(x, y) .* (-1)^(x+y);
end
end img_fp = real(img_fp);
img_fp = mat2gray(img_fp); % 显示结果
imshow(img_fp); max_value = max(max(img_fp));
[row col] = find(img_fp == max_value); disp(['max value is : ', num2str(max_value)]);
disp(['row: ', num2str(row), ' col: ', num2str(col)]);

实验结果:



这是输出结果的图片,实验要求没必要显示出来。



最后求出的(x,y)位置的坐标。

最新文章

  1. regsvr32命令
  2. iOS开发,URL编码和解码
  3. JSP HTML error code
  4. unix时间戳和localtime
  5. SPOJ 416 - Divisibility by 15(贪心)
  6. PHP扩展开发(6) - VS2012下strncasecmp和fopen函数warning
  7. 迎接 Windows Azure 和 DNN 挑战,几分钟内快速构建网站!
  8. AdaBoost中利用Haar特征进行人脸识别算法分析与总结1——Haar特征与积分图
  9. BZOJ 3680: 吊打XXX【模拟退火算法裸题学习,爬山算法学习】
  10. DALI 2.0解码模块
  11. CAS机制与自旋锁
  12. Android 第四次作业
  13. printf和std::cout ...endl
  14. 两道不错的递推dp
  15. GL_子模组过账至总账通过SLA修改会计方法改变科目(案列)
  16. Python系列之 迭代器和生成器
  17. Raw-OS源代码分析之同优先级任务切换
  18. 实现把dgv里的数据完整的复制到一张内存表
  19. 洛谷P4302 [SCOI]字符串折叠 [字符串,区间DP]
  20. PHP学习笔记(13)班级和学生管理---班级

热门文章

  1. MYSQL 级联 添加外键
  2. PS基础教程[6]如何快速制作一寸照片
  3. 关于使用modelsim的一点感想
  4. predis的使用
  5. json数据格式字符串在java中的转移
  6. 阿里云服务器tomcat启动慢解决方案
  7. C#去除数组空格
  8. syslogd日志简介***
  9. spring-aop + memcached 的简单实现
  10. log4net内部调试开启