资源简介
OpenCV实现相位相关图像配准,编译产生库文件
代码片段和文件信息
#include “stdafx.h“
#include “ImageProcessing.h“
#include “stdio.h“
/************************************************************************/
/* 图像傅里叶变换 */
/************************************************************************/
void FFT_2D(IplImage * src CvMat * dst)
{
CvMat * real = cvCreateMat(dst->rows dst->cols CV_64FC1);
CvMat * imag = cvCreateMat(dst->rows dst->cols CV_64FC1);
CvMat * cplx = cvCreateMat(dst->rows dst->cols CV_64FC2);
CvMat temp;
cvGetSubRect(real &temp cvRect(00 src->width src->height));
cvScale(src &temp 1.0 0.0);
if (dst->cols > src->width)
{
cvGetSubRect(real &temp cvRect(src->width 0 dst->cols - src->width src->height));
cvZero(&temp);
}
cvZero(imag);
cvMerge(real imag NULL NULL cplx);
cvReleaseMat(&real);
cvReleaseMat(&imag);
cvDFT(cplx dst CV_DXT_FORWARD src->height);
cvReleaseMat(&cplx);
}
/************************************************************************/
/* 相位相关的图像配准 */
/************************************************************************/
BOOL MethodPhaseCorrelation(IplImage * image1 IplImage * image2 int & iOffX int & iOffY)
{
int iDftX = image1->width;
int iDftY = image1->height;
CvMat * mat1 = cvCreateMat(iDftY iDftX CV_64FC2);
CvMat * mat2 = cvCreateMat(iDftY iDftX CV_64FC2);
FFT_2D(image1 mat1);
FFT_2D(image2 mat2);
cvMulSpectrums(mat1 mat2 mat1 CV_DXT_MUL_CONJ);
for (int i = 0; i < iDftY; i++)
for (int j = 0; j < iDftX; j++)
{
double & re = ((double*)(mat1->data.ptr + mat1->step * i))[j * 2];
double & im = ((double*)(mat1->data.ptr + mat1->step * i))[j * 2 + 1];
double norm = sqrt(re * re + im * im);
re /= norm;
im /= norm;
}
cvDFT(mat1 mat1 CV_DXT_INV_SCALE mat1->rows);
double fMax = -DBL_MAX;
for (int i = 0; i < iDftY; i++)
for (int j = 0; j < iDftX; j++)
{
double re = ((double*)(mat1->data.ptr + mat1->step * i))[j * 2];
if (re > fMax)
{
fMax = re;
iOffX = j;
iOffY = i;
}
}
// FILE * fp1;
//
// fopen_s(&fp1 “data.txt“ “w“);
//
// for (int i = 0; i < iDftY; i++)
// {
// for (int j = 0; j < iDftX; j++)
// {
// double re = ((double*)(mat1->data.ptr + mat1->step * i))[j * 2];
// double im = ((double*)(mat1->data.ptr + mat1->step * i))[j * 2 + 1];
//
// fprintf_s(fp1 “%.4lf\t“ re);
// }
// fprintf_s(fp1 “\n“);
// }
// fclose(fp1);
cvReleaseMat(&mat1);
cvReleaseMat(&mat2);
return TRUE;
}
/************************************************************************/
/* 图像配准 */
/************************************************************************/
BOOL ImageRegistration(int iMethod IplImage * image1 IplImage * image2 int & iOffX int & iOffY)
{
if (iMeth
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6560 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\Debug\BuildLog.htm
文件 18546 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\Debug\ImageProcessing.obj
文件 786432 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\Debug\ImageProcessing.pch
文件 9687 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\Debug\stdafx.obj
文件 224256 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\Debug\vc90.idb
文件 159744 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\Debug\vc90.pdb
文件 3118 2009-11-05 18:54 Phase Correlation\ImageProcessing\ImageProcessing\ImageProcessing.cpp
文件 4269 2009-11-05 15:25 Phase Correlation\ImageProcessing\ImageProcessing\ImageProcessing.vcproj
文件 1377 2009-11-05 18:56 Phase Correlation\ImageProcessing\ImageProcessing\ImageProcessing.vcproj.Ker.Administrator.user
文件 1258 2009-11-05 14:45 Phase Correlation\ImageProcessing\ImageProcessing\ReadMe.txt
文件 302 2009-11-05 14:45 Phase Correlation\ImageProcessing\ImageProcessing\stdafx.cpp
文件 371 2009-11-05 14:45 Phase Correlation\ImageProcessing\ImageProcessing\stdafx.h
文件 765 2009-11-05 14:45 Phase Correlation\ImageProcessing\ImageProcessing\targetver.h
文件 911 2009-11-05 14:45 Phase Correlation\ImageProcessing\ImageProcessing.sln
..A..H. 18432 2009-11-05 18:56 Phase Correlation\ImageProcessing\ImageProcessing.suo
文件 617 2009-11-05 16:35 Phase Correlation\Include\ImageProcessing.h
文件 29008 2009-11-05 18:54 Phase Correlation\Lib\ImageProcessing.lib
目录 0 2009-11-05 18:57 Phase Correlation\ImageProcessing\ImageProcessing\Debug
目录 0 2009-11-05 18:57 Phase Correlation\ImageProcessing\ImageProcessing
目录 0 2009-11-05 18:57 Phase Correlation\ImageProcessing
目录 0 2009-11-05 18:57 Phase Correlation\Include
目录 0 2009-11-05 18:57 Phase Correlation\Lib
目录 0 2009-11-05 18:57 Phase Correlation
----------- --------- ---------- ----- ----
1265653 23
相关资源
- 老外图像配准的ppt - lecture02
- opencv彩色图转换为灰度图并保存
- vgg_generated_80.i
- 相位相关法.rar
- opencv-图片相似度对比代码-感知哈希算
- opencv2.44附加依赖项
- 总结-图像配准算法
- rk3288平台深度学习框架caffe+opencv环境
-
cascadexm
l.rar - 图片上加文字或者数字opencv
- OpenCV切边案例-01
- 提取二值图像中的最大轮廓OpenCV版
- Opencv 目标检测和识别
- opencv实现特征点的检测与匹配
- Qt魔方还原lesson5-opencv识别颜色
- opencv 标定 带图片
- ippicv_2017u2_lnx_intel64_20170418.tgz
- 基于fft的图像配准资料
- 图像配准技术
- cxcore.lib的生成工程
- Caffe安装支持文件
- opencv调用摄像头捕捉并进行人脸识别
- opencv+串口通讯
- 图像处理源码 opencv图像处理源码
- opencv2.4.9opencv_createsamples.exe和opencv_h
- LSD-直线检测源码
- Opencv 特征点提取 代码
- Opencv 各种特征点提取和匹配
- opencv调用摄像头并截图保存
- KinectV2 opencv qt 实现平面测量
评论
共有 条评论