数字图像处理实验(9):PROJECT 04-05,Correlation in the Frequency Domain
来源:互联网 发布:城市公交软件 编辑:程序博客网 时间:2024/06/10 18:45
实验要求:
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 Domainclose 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); endend% 傅里叶变换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); endendimg_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)位置的坐标。
- 数字图像处理实验(9):PROJECT 04-05,Correlation in the Frequency Domain
- 数字图像处理实验(2):PROJECT 02-02, Reducing the Number of Gray Levels in an Image
- 数字图像处理实验(7):PROJECT 04-03 , Lowpass Filtering
- 数字图像处理实验(13):PROJECT 05-04,Parametric Wiener Filter
- 数字图像处理实验(8):PROJECT 04-04,Highpass Filtering Using a Lowpass Image
- 数字图像处理实验(10):PROJECT 05-01 [Multiple Uses],Noise Generators
- 数字图像处理实验(11):PROJECT 05-02,Noise Reduction Using a Median Filter
- 数字图像处理实验(12):PROJECT 05-03,Periodic Noise Reduction Using a Notch Filter
- 数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform
- 数字图像处理实验(6):PROJECT 04-02,Fourier Spectrum and Average Value
- 数字图像处理实验(17):PROJECT 06-04,Color Image Segmentation
- [cv] convolution in frequency domain
- 数字图像处理实验(4):PROJECT 02-04 [Multiple Uses],Zooming and Shrinking Images by Bilinear Interpolation
- 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Halftoning
- 数字图像处理实验(3):PROJECT 02-03, Zooming and Shrinking Images by Pixel Replication
- 数字图像处理实验(14):PROJECT 06-01,Web-Safe Colors
- 数字图像处理实验(15):PROJECT 06-02,Pseudo-Color Image Processing
- 数字图像处理实验(16):PROJECT 06-03,Color Image Enhancement by Histogram Processing
- 在web项目中添加文本编辑器 ckeditor
- 屏幕适配之带虚拟按键手机屏幕适配
- 关于iOS时间的传递和响应机制_转载自马在路上大神的博客
- Git .gitignore
- 网站需要测试的五个方面
- 数字图像处理实验(9):PROJECT 04-05,Correlation in the Frequency Domain
- 分享进入内网的详细步骤
- 开源安卓Http文件下载框架file-downloader的使用
- iOS开发UI篇—UITabBarController简单介绍
- eclipse debug 断点调试(beta)
- 辩论6弱者为什么有理?
- 线程的挂起-睡眠-阻塞
- VS2015配置QT5环境
- linux线程剖析(Part1)—1个“假“的tcb