20190710记录:去掉中转图,直接以1280*1024进行反坐标计算,填补pbFinal。

2023-06-07,,

1、记录:去掉中转图,直接以1280*1024进行反坐标计算。pbFinal=1280*1024。

// Imagejoint.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Imagejoint.h"
#include "math.h"
#include <afxwin.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <atlimage.h>//CImage类
#include <locale.h> // The one and only application object CWinApp theApp; using namespace std;
//双三次插值系数
double fs(double w)
{
double a=-0.5;
double fs;
if (abs(w)<=)
fs=(a+)*pow(abs(w),)-(a+)*pow(abs(w),)+;
else if (abs(w)>&&abs(w)<=)
fs=a*pow(abs(w),)-*a*pow(abs(w),)+*a*abs(w)-*a;
else
fs=;
return fs;
} HRESULT Imagejoint(PBYTE pbSrc,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal); int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{ int nRetCode = ;//表示整数类型的函数返回码。n表示整数类型,Ret是Return的缩写,表示返回值,Code表示代码。
setlocale(LC_ALL,"chs");
HMODULE hModule = ::GetModuleHandle(NULL); if (hModule != NULL)
{
// initialize MFC and print and error on failure
CImage cImage;
HRESULT hResult; //初始化一些变量
int iWidth,iHeight,iBytePerPixel,iPitch;
int x,y;
PBYTE pbSrc=NULL,pbFinal=NULL;//源图、目标图
PBYTE pbImage=NULL;//load图像后存在这
PDWORD pdwImage=NULL;//用于保存图像
double dbZoom=2.25; CString str = "frame1.bmp";
LPCTSTR filename = (LPCTSTR)str;
do{
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), ))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = ;
break;
}
//Load 图像到cImage对象中
hResult=cImage.Load(filename);
if(hResult!=ERROR_SUCCESS)
{
_tprintf(_T("源图像文件名错误!\n"));
nRetCode= -;
break;
} iWidth=cImage.GetWidth();
iHeight=cImage.GetHeight();
//分配源图内存
pbSrc = (PBYTE)malloc(iWidth*iHeight);
pbFinal = (PBYTE)malloc(*);
//while (dbZoom<3);
//{
//分配目标图内存 if(pbSrc==NULL || pbFinal==NULL )
{
_tprintf(_T("内存申请错误!\n"));
nRetCode= -;
break;
}
//cImage数据存到pbImage,后再转换为源灰度图pbSrc
iPitch=cImage.GetPitch();
iBytePerPixel=(cImage.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage.Destroy();
//TO DO:执行操作
hResult=Imagejoint(pbSrc,iWidth,iHeight,dbZoom,pbFinal);
if(hResult!=ERROR_SUCCESS)
{
_tprintf(_T("图像处理错误!\n"));
nRetCode= -;
break;
} //处理后保存图像
iWidth=;
iHeight=;
cImage.Create(iWidth,-iHeight,);
iPitch=cImage.GetPitch();
for(y=;y<iHeight;y++)
{
pdwImage=(PDWORD)(PBYTE(cImage.GetBits())+iPitch*y);
for(x=;x<iWidth;x++)
{
pdwImage[x]=pbFinal[y*iWidth+x]*0x10101;
}
}
//待保存图像文件名
CString name1="target";
CString name2;
name2.Format(_T("%.2lf"),dbZoom); CString csTagName;
csTagName=name1+name2;
//CString csTagName="target";
csTagName.Trim();
csTagName.MakeUpper();
if(csTagName.Right()!=_T(".BMP") ) csTagName.Append(_T(".BMP"));
hResult=cImage.Save(csTagName);
if(hResult!=ERROR_SUCCESS)
{
_tprintf(_T("图像结果保存错误!\n"));
nRetCode= -;
break;
}
_tprintf(_T("图像处理成功!\n"));
nRetCode= ERROR_SUCCESS;
break; //dbZoom=dbZoom+0.5;
//} }while();
if(pbSrc) free(pbSrc);
if(pbFinal) free(pbFinal); }
else
{
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = ;
}
getchar();
return nRetCode;
} HRESULT Imagejoint(PBYTE pbSrc,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal)
{
double phase[]={};//16相位,包含端点存在33个距离
for (int i=;i<;i++)
{
double i2=1.0*i;
phase[i]=fs(i2/);
} //旋转中心为图像中心
double rx0=iWidth;
double ry0=iHeight;
double srcx,srcy,u,v;
int xOr,yOr;
int newWidth=ceil(dbZoom*iWidth);
int newHeight=ceil(dbZoom*iHeight); for (int y=;y<;y++)
{
for (int x=;x<;x++)
{ srcx=(double)(newWidth/-+x)/dbZoom;
srcy=(double)(newHeight/-+y)/dbZoom ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; if( !(srcx>= && srcx<=iWidth && srcy>= && srcy<=iHeight))
{
pbFinal[y*+x]=;//
}
else
{
double middle=
pbSrc[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
}
}
}
return ERROR_SUCCESS;
}

2、外圈需拼接

目前dbZoom都是表示的,中间处的放大倍数。

由于目前测试图像是768*576的。

在dbZoom<1.75左右时,其外圈仍需补充拼接。

先进行简单测试:发现需补充拼接的点为,映射后落在原图外的部分。暂时仍采用同一图像进行外圈的拼接。

// Imagejoint.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Imagejoint.h"
#include <afxwin.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <atlimage.h>//CImage类
#include <locale.h>
#include "math.h"
using namespace std;
//双三次插值系数
double fs(double w)
{
double a=-0.5;
double fs;
if (abs(w)<=)
fs=(a+)*pow(abs(w),)-(a+)*pow(abs(w),)+;
else if (abs(w)>&&abs(w)<=)
fs=a*pow(abs(w),)-*a*pow(abs(w),)+*a*abs(w)-*a;
else
fs=;
return fs;
} HRESULT Imagejoint(PBYTE pbSrc,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal); int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{ int nRetCode = ;//表示整数类型的函数返回码。n表示整数类型,Ret是Return的缩写,表示返回值,Code表示代码。
setlocale(LC_ALL,"chs");
HMODULE hModule = ::GetModuleHandle(NULL); if (hModule != NULL)
{
// initialize MFC and print and error on failure
CImage cImage;
HRESULT hResult; //初始化一些变量
int iWidth,iHeight,iBytePerPixel,iPitch;
int x,y;
PBYTE pbSrc=NULL,pbFinal=NULL;//源图、目标图
PBYTE pbImage=NULL;//load图像后存在这
PDWORD pdwImage=NULL;//用于保存图像
double dbZoom=1.25; CString str = "frame1.bmp";
LPCTSTR filename = (LPCTSTR)str;
do{
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), ))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = ;
break;
}
//Load 图像到cImage对象中
hResult=cImage.Load(filename);
if(hResult!=ERROR_SUCCESS)
{
_tprintf(_T("源图像文件名错误!\n"));
nRetCode= -;
break;
} iWidth=cImage.GetWidth();
iHeight=cImage.GetHeight();
//分配源图内存
pbSrc = (PBYTE)malloc(iWidth*iHeight);
pbFinal = (PBYTE)malloc(*);
//while (dbZoom<3);
//{
//分配目标图内存 if(pbSrc==NULL || pbFinal==NULL )
{
_tprintf(_T("内存申请错误!\n"));
nRetCode= -;
break;
}
//cImage数据存到pbImage,后再转换为源灰度图pbSrc
iPitch=cImage.GetPitch();
iBytePerPixel=(cImage.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage.Destroy();
//TO DO:执行操作
hResult=Imagejoint(pbSrc,iWidth,iHeight,dbZoom,pbFinal);
if(hResult!=ERROR_SUCCESS)
{
_tprintf(_T("图像处理错误!\n"));
nRetCode= -;
break;
} //处理后保存图像
iWidth=;
iHeight=;
cImage.Create(iWidth,-iHeight,);
iPitch=cImage.GetPitch();
for(y=;y<iHeight;y++)
{
pdwImage=(PDWORD)(PBYTE(cImage.GetBits())+iPitch*y);
for(x=;x<iWidth;x++)
{
pdwImage[x]=pbFinal[y*iWidth+x]*0x10101;
}
}
//待保存图像文件名
CString name1="target";
CString name2;
name2.Format(_T("%.2lf"),dbZoom); CString csTagName;
csTagName=name1+name2;
//CString csTagName="target";
csTagName.Trim();
csTagName.MakeUpper();
if(csTagName.Right()!=_T(".BMP") ) csTagName.Append(_T(".BMP"));
hResult=cImage.Save(csTagName);
if(hResult!=ERROR_SUCCESS)
{
_tprintf(_T("图像结果保存错误!\n"));
nRetCode= -;
break;
}
_tprintf(_T("图像处理成功!\n"));
nRetCode= ERROR_SUCCESS;
break; //dbZoom=dbZoom+0.5;
//} }while();
if(pbSrc) free(pbSrc);
if(pbFinal) free(pbFinal); }
else
{
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = ;
}
getchar();
return nRetCode;
} HRESULT Imagejoint(PBYTE pbSrc,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal)
{
double phase[]={};//16相位,包含端点存在33个距离
for (int i=;i<;i++)
{
double i2=1.0*i;
phase[i]=fs(i2/);
} //旋转中心为图像中心
double rx0=iWidth;
double ry0=iHeight;
double srcx,srcy,u,v;
int xOr,yOr;
int newWidth=ceil(dbZoom*iWidth);
int newHeight=ceil(dbZoom*iHeight); for (int y=;y<;y++)
{
for (int x=;x<;x++)
{ srcx=(double)(newWidth/-+x)/dbZoom;
srcy=(double)(newHeight/-+y)/dbZoom ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; if( !(srcx>= && srcx<=iWidth && srcy>= && srcy<=iHeight))//越界部分需拼接为外圈大视场图像,远景
{ srcx=(double)(newWidth/-+x)/(*dbZoom);
srcy=(double)(newHeight/-+y)/(*dbZoom) ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; double middle=
pbSrc[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
//pbFinal[y*1280+x]=255;
}
else
{
double middle=
pbSrc[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
}
}
}
return ERROR_SUCCESS;
}

3、初步改为利用双图拼接而来,但是其中一些参数不对,拼接位置不对。注意:代码起始阶段的图像长宽和内存分配,默认是两图相同的。

// Imagejoint.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Imagejoint.h"
#include <afxwin.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <atlimage.h>//CImage类
#include <locale.h>
#include "math.h"
using namespace std;
//双三次插值系数
double fs(double w)
{
double a=-0.5;
double fs;
if (abs(w)<=)
fs=(a+)*pow(abs(w),)-(a+)*pow(abs(w),)+;
else if (abs(w)>&&abs(w)<=)
fs=a*pow(abs(w),)-*a*pow(abs(w),)+*a*abs(w)-*a;
else
fs=;
return fs;
} HRESULT Imagejoint(PBYTE pbSrc1,PBYTE pbSrc2,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal); int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{ int nRetCode = ;//表示整数类型的函数返回码。n表示整数类型,Ret是Return的缩写,表示返回值,Code表示代码。
setlocale(LC_ALL,"chs");
HMODULE hModule = ::GetModuleHandle(NULL); if (hModule != NULL)
{
// initialize MFC and print and error on failure
CImage cImage_far;
CImage cImage_near; HRESULT hResult1,hResult2; //初始化一些变量
int iWidth,iHeight,iBytePerPixel,iPitch;
int x,y;
PBYTE pbSrc1=NULL,pbSrc2=NULL,pbFinal=NULL;//源图、目标图
PBYTE pbImage=NULL;//load图像后存在这
PDWORD pdwImage=NULL;//用于保存图像
double dbZoom=1.25; CString str = "far-frame1.bmp";
CString str2 = "near-frame1.bmp";
LPCTSTR filename1 = (LPCTSTR)str;
LPCTSTR filename2 = (LPCTSTR)str2;
do{
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), ))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = ;
break;
}
//Load 图像到cImage对象中
hResult1=cImage_far.Load(filename1);
hResult2=cImage_near.Load(filename2);
if(hResult1!=ERROR_SUCCESS||hResult2!=ERROR_SUCCESS)
{
_tprintf(_T("源图像文件名错误!\n"));
nRetCode= -;
break;
} iWidth=cImage_far.GetWidth();
iHeight=cImage_far.GetHeight();
//分配源图内存
pbSrc1 = (PBYTE)malloc(iWidth*iHeight);
pbSrc2 = (PBYTE)malloc(iWidth*iHeight);
pbFinal = (PBYTE)malloc(*);
//while (dbZoom<3);
//{
//分配目标图内存 if(pbSrc1==NULL||pbSrc2==NULL || pbFinal==NULL )
{
_tprintf(_T("内存申请错误!\n"));
nRetCode= -;
break;
}
//cImage数据存到pbImage,后再转换为源灰度图pbSrc
iPitch=cImage_far.GetPitch();
iBytePerPixel=(cImage_far.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage_far.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc1[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage_far.Destroy(); iPitch=cImage_near.GetPitch();
iBytePerPixel=(cImage_near.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage_near.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc2[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage_near.Destroy();
//TO DO:执行操作
hResult1=Imagejoint(pbSrc1,pbSrc2,iWidth,iHeight,dbZoom,pbFinal);
if(hResult1!=ERROR_SUCCESS)
{
_tprintf(_T("图像处理错误!\n"));
nRetCode= -;
break;
} //处理后保存图像
iWidth=;
iHeight=;
cImage_far.Create(iWidth,-iHeight,);
iPitch=cImage_far.GetPitch();
for(y=;y<iHeight;y++)
{
pdwImage=(PDWORD)(PBYTE(cImage_far.GetBits())+iPitch*y);
for(x=;x<iWidth;x++)
{
pdwImage[x]=pbFinal[y*iWidth+x]*0x10101;
}
}
//待保存图像文件名
CString name1="target";
CString name2;
name2.Format(_T("%.2lf"),dbZoom); CString csTagName;
csTagName=name1+name2;
//CString csTagName="target";
csTagName.Trim();
csTagName.MakeUpper();
if(csTagName.Right()!=_T(".BMP") ) csTagName.Append(_T(".BMP"));
hResult1=cImage_far.Save(csTagName);
if(hResult1!=ERROR_SUCCESS)
{
_tprintf(_T("图像结果保存错误!\n"));
nRetCode= -;
break;
}
_tprintf(_T("图像处理成功!\n"));
nRetCode= ERROR_SUCCESS;
break; //dbZoom=dbZoom+0.5;
//} }while();
if(pbSrc1) free(pbSrc1);
if(pbSrc2) free(pbSrc2);
if(pbFinal) free(pbFinal); }
else
{
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = ;
}
getchar();
return nRetCode;
} HRESULT Imagejoint(PBYTE pbSrc1,PBYTE pbSrc2,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal)
{
double phase[]={};//16相位,包含端点存在33个距离
for (int i=;i<;i++)
{
double i2=1.0*i;
phase[i]=fs(i2/);
} //旋转中心为图像中心
double rx0=iWidth;
double ry0=iHeight;
double srcx,srcy,u,v;
int xOr,yOr;
int newWidth=ceil(dbZoom*iWidth);
int newHeight=ceil(dbZoom*iHeight); for (int y=;y<;y++)
{
for (int x=;x<;x++)
{ srcx=(double)(newWidth/-+x)/dbZoom;
srcy=(double)(newHeight/-+y)/dbZoom ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; if( !(srcx>= && srcx<=iWidth && srcy>= && srcy<=iHeight))//越界部分需拼接为外圈大视场图像,远景
{ srcx=(double)(newWidth/-+x)/(*dbZoom);
srcy=(double)(newHeight/-+y)/(*dbZoom) ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; double middle=
pbSrc1[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc1[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc1[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc1[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc1[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc1[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc1[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc1[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc1[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc1[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc1[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc1[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
//pbFinal[y*1280+x]=255;
}
else
{
double middle=
pbSrc2[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc2[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc2[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc2[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc2[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc2[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc2[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc2[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc2[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc2[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc2[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc2[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
}
}
}
return ERROR_SUCCESS;
}

4、对拼接位置修正,x+6,y-3。右6,上3。

// Imagejoint.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Imagejoint.h"
#include <afxwin.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <atlimage.h>//CImage类
#include <locale.h>
#include "math.h"
using namespace std;
//双三次插值系数
double fs(double w)
{
double a=-0.5;
double fs;
if (abs(w)<=)
fs=(a+)*pow(abs(w),)-(a+)*pow(abs(w),)+;
else if (abs(w)>&&abs(w)<=)
fs=a*pow(abs(w),)-*a*pow(abs(w),)+*a*abs(w)-*a;
else
fs=;
return fs;
} HRESULT Imagejoint(PBYTE pbSrc1,PBYTE pbSrc2,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal); int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{ int nRetCode = ;//表示整数类型的函数返回码。n表示整数类型,Ret是Return的缩写,表示返回值,Code表示代码。
setlocale(LC_ALL,"chs");
HMODULE hModule = ::GetModuleHandle(NULL); if (hModule != NULL)
{
// initialize MFC and print and error on failure
CImage cImage_far;
CImage cImage_near; HRESULT hResult1,hResult2; //初始化一些变量
int iWidth,iHeight,iBytePerPixel,iPitch;
int x,y;
PBYTE pbSrc1=NULL,pbSrc2=NULL,pbFinal=NULL;//源图、目标图
PBYTE pbImage=NULL;//load图像后存在这
PDWORD pdwImage=NULL;//用于保存图像
double dbZoom=1.5; CString str = "far-frame1.bmp";
CString str2 = "near-frame1.bmp";
LPCTSTR filename1 = (LPCTSTR)str;
LPCTSTR filename2 = (LPCTSTR)str2;
do{
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), ))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = ;
break;
}
//Load 图像到cImage对象中
hResult1=cImage_far.Load(filename1);
hResult2=cImage_near.Load(filename2);
if(hResult1!=ERROR_SUCCESS||hResult2!=ERROR_SUCCESS)
{
_tprintf(_T("源图像文件名错误!\n"));
nRetCode= -;
break;
} iWidth=cImage_far.GetWidth();
iHeight=cImage_far.GetHeight();
//分配源图内存
pbSrc1 = (PBYTE)malloc(iWidth*iHeight);
pbSrc2 = (PBYTE)malloc(iWidth*iHeight);
pbFinal = (PBYTE)malloc(*);
//while (dbZoom<3);
//{
//分配目标图内存 if(pbSrc1==NULL||pbSrc2==NULL || pbFinal==NULL )
{
_tprintf(_T("内存申请错误!\n"));
nRetCode= -;
break;
}
//cImage数据存到pbImage,后再转换为源灰度图pbSrc
iPitch=cImage_far.GetPitch();
iBytePerPixel=(cImage_far.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage_far.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc1[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage_far.Destroy(); iPitch=cImage_near.GetPitch();
iBytePerPixel=(cImage_near.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage_near.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc2[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage_near.Destroy();
//TO DO:执行操作
hResult1=Imagejoint(pbSrc1,pbSrc2,iWidth,iHeight,dbZoom,pbFinal);
if(hResult1!=ERROR_SUCCESS)
{
_tprintf(_T("图像处理错误!\n"));
nRetCode= -;
break;
} //处理后保存图像
iWidth=;
iHeight=;
cImage_far.Create(iWidth,-iHeight,);
iPitch=cImage_far.GetPitch();
for(y=;y<iHeight;y++)
{
pdwImage=(PDWORD)(PBYTE(cImage_far.GetBits())+iPitch*y);
for(x=;x<iWidth;x++)
{
pdwImage[x]=pbFinal[y*iWidth+x]*0x10101;
}
}
//待保存图像文件名
CString name1="target";
CString name2;
name2.Format(_T("%.2lf"),dbZoom); CString csTagName;
csTagName=name1+name2;
//CString csTagName="target";
csTagName.Trim();
csTagName.MakeUpper();
if(csTagName.Right()!=_T(".BMP") ) csTagName.Append(_T(".BMP"));
hResult1=cImage_far.Save(csTagName);
if(hResult1!=ERROR_SUCCESS)
{
_tprintf(_T("图像结果保存错误!\n"));
nRetCode= -;
break;
}
_tprintf(_T("图像处理成功!\n"));
nRetCode= ERROR_SUCCESS;
break; //dbZoom=dbZoom+0.5;
//} }while();
if(pbSrc1) free(pbSrc1);
if(pbSrc2) free(pbSrc2);
if(pbFinal) free(pbFinal); }
else
{
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = ;
}
getchar();
return nRetCode;
} HRESULT Imagejoint(PBYTE pbSrc1,PBYTE pbSrc2,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal)
{
double phase[]={};//16相位,包含端点存在33个距离
for (int i=;i<;i++)
{
double i2=1.0*i;
phase[i]=fs(i2/);
} //旋转中心为图像中心
double rx0=iWidth;
double ry0=iHeight;
double srcx,srcy,u,v;
int xOr,yOr;
int newWidth=ceil(dbZoom*iWidth);
int newHeight=ceil(dbZoom*iHeight); for (int y=;y<;y++)
{
for (int x=;x<;x++)
{ srcx=(double)(newWidth/-+x)/dbZoom;
srcy=(double)(newHeight/-+y)/dbZoom ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; //Matlab中测试获取定值(34:541 -Y,41:728 -X),需要微调。
if( !(srcx>= && srcx<= && srcy>= && srcy<=))//越界部分需拼接为外圈大视场图像,远景
{ srcx=(double)(newWidth-+x)/(*dbZoom)+;//补偏差
srcy=(double)(newHeight-+y)/(*dbZoom)-;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; double middle=
pbSrc1[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc1[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc1[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc1[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc1[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc1[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc1[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc1[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc1[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc1[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc1[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc1[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
//pbFinal[y*1280+x]=255;
}
else
{
double middle=
pbSrc2[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc2[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc2[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc2[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc2[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc2[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc2[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc2[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc2[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc2[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc2[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc2[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
}
}
}
return ERROR_SUCCESS;
}

5、加入dbZoom自循环。

for(dbZoom=1.25;dbZoom<=2.25;dbZoom+=0.25)

但要注意!由于之后有:cImage_far.Destroy();和cImage_near.Destroy();

因此循环内应包含!CImage cImage_far;CImage cImage_near;

// Imagejoint.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Imagejoint.h"
#include <afxwin.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <atlimage.h>//CImage类
#include <locale.h>
#include "math.h"
using namespace std;
//双三次插值系数
double fs(double w)
{
double a=-0.5;
double fs;
if (abs(w)<=)
fs=(a+)*pow(abs(w),)-(a+)*pow(abs(w),)+;
else if (abs(w)>&&abs(w)<=)
fs=a*pow(abs(w),)-*a*pow(abs(w),)+*a*abs(w)-*a;
else
fs=;
return fs;
} HRESULT Imagejoint(PBYTE pbSrc1,PBYTE pbSrc2,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal); int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{ int nRetCode = ;//表示整数类型的函数返回码。n表示整数类型,Ret是Return的缩写,表示返回值,Code表示代码。
setlocale(LC_ALL,"chs");
HMODULE hModule = ::GetModuleHandle(NULL); if (hModule != NULL)
{ HRESULT hResult1,hResult2;
//初始化一些变量
int iWidth,iHeight,iBytePerPixel,iPitch;
int x,y;
PBYTE pbSrc1=NULL,pbSrc2=NULL,pbFinal=NULL;//源图、目标图
PBYTE pbImage=NULL;//load图像后存在这
PDWORD pdwImage=NULL;//用于保存图像
double dbZoom=1.25; for(dbZoom=1.25;dbZoom<=2.25;dbZoom+=0.25)
{
CImage cImage_far;
CImage cImage_near; CString str = "far-frame1.bmp";
CString str2 = "near-frame1.bmp";
LPCTSTR filename1 = (LPCTSTR)str;
LPCTSTR filename2 = (LPCTSTR)str2; if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), ))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = ; }
//Load 图像到cImage对象中
hResult1=cImage_far.Load(filename1);
hResult2=cImage_near.Load(filename2);
if(hResult1!=ERROR_SUCCESS||hResult2!=ERROR_SUCCESS)
{
_tprintf(_T("源图像文件名错误!\n"));
nRetCode= -; } iWidth=cImage_far.GetWidth();
iHeight=cImage_far.GetHeight();
//分配源图内存
pbSrc1 = (PBYTE)malloc(iWidth*iHeight);
pbSrc2 = (PBYTE)malloc(iWidth*iHeight);
//分配目标图内存
pbFinal = (PBYTE)malloc(*);
if(pbSrc1==NULL||pbSrc2==NULL || pbFinal==NULL )
{
_tprintf(_T("内存申请错误!\n"));
nRetCode= -; }
//cImage数据存到pbImage,后再转换为源灰度图pbSrc
iPitch=cImage_far.GetPitch();
iBytePerPixel=(cImage_far.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage_far.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc1[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage_far.Destroy(); iPitch=cImage_near.GetPitch();
iBytePerPixel=(cImage_near.GetBPP()+)/;
if(iBytePerPixel==)
{
for(y=;y<iHeight;y++)
{ //load的图像数据放到pbImage
pbImage=(PBYTE)(PBYTE(cImage_near.GetBits())+iPitch*y);//得到的是图像初始像素地址
for(x=;x<iWidth;x++)
{
//pbImage转换为灰度图pbSrc
pbSrc2[y*iWidth+x]=(pbImage[*x]*0.15+pbImage[*x+]*0.55+pbImage[*x+]*0.3);
}
}
}
cImage_near.Destroy(); //执行操作
hResult1=Imagejoint(pbSrc1,pbSrc2,iWidth,iHeight,dbZoom,pbFinal);
if(hResult1!=ERROR_SUCCESS)
{
_tprintf(_T("图像处理错误!\n"));
nRetCode= -; }
//处理后保存图像
iWidth=;
iHeight=;
cImage_far.Create(iWidth,-iHeight,);
iPitch=cImage_far.GetPitch();
for(y=;y<iHeight;y++)
{
pdwImage=(PDWORD)(PBYTE(cImage_far.GetBits())+iPitch*y);
for(x=;x<iWidth;x++)
{
pdwImage[x]=pbFinal[y*iWidth+x]*0x10101;
}
}
//可预存待保存图像文件名
CString name1="target";
CString name2;
name2.Format(_T("%.2lf"),dbZoom);
CString csTagName;
csTagName=name1+name2; csTagName.Trim();
csTagName.MakeUpper();
if(csTagName.Right()!=_T(".BMP") ) csTagName.Append(_T(".BMP"));
hResult1=cImage_far.Save(csTagName);
if(hResult1!=ERROR_SUCCESS)
{
_tprintf(_T("图像结果保存错误!\n"));
nRetCode= -; }
_tprintf(_T("图像处理成功!\n"));
nRetCode= ERROR_SUCCESS; if(pbSrc1) free(pbSrc1);
if(pbSrc2) free(pbSrc2);
if(pbFinal) free(pbFinal);
}//对应+=0.25倍数的for循环。 }
else
{
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = ;
}
getchar();
return nRetCode;
} HRESULT Imagejoint(PBYTE pbSrc1,PBYTE pbSrc2,int iWidth,int iHeight,double dbZoom,PBYTE pbFinal)
{
double phase[]={};//16相位,包含端点存在33个距离
for (int i=;i<;i++)
{
double i2=1.0*i;
phase[i]=fs(i2/);
} //旋转中心为图像中心
double rx0=iWidth;
double ry0=iHeight;
double srcx,srcy,u,v;
int xOr,yOr;
int newWidth=ceil(dbZoom*iWidth);
int newHeight=ceil(dbZoom*iHeight); for (int y=;y<;y++)
{
for (int x=;x<;x++)
{ srcx=(double)(newWidth/-+x)/dbZoom;
srcy=(double)(newHeight/-+y)/dbZoom ;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; //Matlab中测试获取定值(34:541 -Y,41:728 -X),需要微调。
if( !(srcx>= && srcx<= && srcy>= && srcy<=))//越界部分需拼接为外圈大视场图像,远景
{ srcx=(double)(newWidth-+x)/(*dbZoom)+;//补偏差
srcy=(double)(newHeight-+y)/(*dbZoom)-;
xOr = floor(srcx);
yOr = floor(srcy);
u=srcx-xOr;
v=srcy-yOr; int phasex=floor(*u+0.5);//16相位
int phasey=floor(*v+0.5);
double A1,B1,C1,D1,A2,B2,C2,D2;
A1=phase[+phasex];
B1=phase[phasex];
C1=phase[-phasex];
D1=phase[-phasex]; A2=phase[+phasey];
B2=phase[phasey];
C2=phase[-phasey];
D2=phase[-phasey]; double middle=
pbSrc1[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc1[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc1[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc1[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc1[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc1[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc1[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc1[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc1[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc1[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc1[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc1[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc1[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
//pbFinal[y*1280+x]=255;
}
else
{
double middle=
pbSrc2[(yOr-)*iWidth+(xOr-)]*A1*A2+
pbSrc2[(yOr)*iWidth+(xOr-)]*A1*B2+
pbSrc2[(yOr+)*iWidth+(xOr-)]*A1*C2+
pbSrc2[(yOr+)*iWidth+(xOr-)]*A1*D2+ pbSrc2[(yOr-)*iWidth+(xOr)]*B1*A2+
pbSrc2[(yOr)*iWidth+(xOr)]*B1*B2+
pbSrc2[(yOr+)*iWidth+(xOr)]*B1*C2+
pbSrc2[(yOr+)*iWidth+(xOr)]*B1*D2+ pbSrc2[(yOr-)*iWidth+(xOr+)]*C1*A2+
pbSrc2[(yOr)*iWidth+(xOr+)]*C1*B2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*C1*C2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*C1*D2+ pbSrc2[(yOr-)*iWidth+(xOr+)]*D1*A2+
pbSrc2[(yOr)*iWidth+(xOr+)]*D1*B2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*D1*C2+
pbSrc2[(yOr+)*iWidth+(xOr+)]*D1*D2; if(middle<=&&middle>=)
pbFinal[y*+x]=middle;
else if(middle>)
pbFinal[y*+x]=;
else
pbFinal[y*+x]=;
}
}
}
return ERROR_SUCCESS;
}

至此,基本完成效果仿真。

但目前只是针对图像的。下面考虑如何读取.avi格式的视频文件处理。

20190710记录:去掉中转图,直接以1280*1024进行反坐标计算,填补pbFinal。的相关教程结束。

《20190710记录:去掉中转图,直接以1280*1024进行反坐标计算,填补pbFinal。.doc》

下载本文的Word格式文档,以方便收藏与打印。