就是有两幅图,并且有部分是相同的,现在要把这两幅图合并成一幅图,就好比,要拍一列火车,当然一张照片拍不下,用了好几张照片,最后想把这些照片合并成一张。用一张照片显示火车。
老大们,有谁能给我这样的代码,我给他另开贴,加300分。谢谢
老大们,有谁能给我这样的代码,我给他另开贴,加300分。谢谢
解决方案 »
- 添加列表框控件出错。。。。
- 如何用VC写一个后台运行的程序
- 已經知道是知道是標記處有問題,但不知道問題的原因,m_pConnection是theApp的全局變量,並且這句在同一個類下的其他函數中沒有問題,高手指教
- 在eVC上能否给Picture控件加上滚动条,垂直与水平滚动条,以达到当图片太大时,能够通过拉动滚动条来观看图片。
- 请问编程如何实现ping操作呢?windows 有api函数实现ping操作的吗?
- 怎样获得开机开了多少时间?
- 奇快问题,怀疑是MFC的bug,Dialog上面建立一个PropertySheet,结果就不能再建立非Child窗口了
- 高分寻求封装好的ADO操作类,急,在线等待,嫌分数不够,我可以再开帖子加,但是要快啊
- ####### 第一次用VC写XML但不知道如何用引用msxml啊########
- 关于监控windows下的文件信息
- DllRegisterServer in MyActiveX.dll failed,Return Code was :0x8007007e????
- 如何选中POPUP型子菜单?(即在其内容前打勾)
这种方法有:相位相关度法,模板法等,好像还要用到金字塔技术,只知道没做过.相位相关度法我做过没做成功,不知错在那里,代码如下:
/*
void CCh1_1App::OnPictureLink()
{
int i,j,ii;
int nDocCount=0;//记录文档的数量
CCh1_1Doc *pDoc[5];//文档指针
HDIB hDIB[5];//图像句柄
LPSTR lpDIB[5];//指向DIB的指针
LPSTR lpDIBBits[5];//指向DIB数据区的指针
for(i=0;i<5;i++)
{
pDoc[i]=NULL;
hDIB[i]=NULL;
lpDIB[i]=NULL;
lpDIBBits[i]=NULL;
}
POSITION position=m_pDocTemplate->GetFirstDocPosition( );
for(i=0;position!=NULL;i++,nDocCount++)
{
pDoc[i]=(CCh1_1Doc *)m_pDocTemplate->GetNextDoc(position) ;
hDIB[i]=pDoc[i]->GetHDIB();
lpDIB[i]=(LPSTR) ::GlobalLock(hDIB[i]);
lpDIBBits[i] = ::FindDIBBits(lpDIB[i]);
}
if(nDocCount<=1)
{
AfxMessageBox("请打开两幅以上大小相等的图像");
return;
}
if(nDocCount>5)
{
AfxMessageBox("最多只能打开五幅大小相等的图像");
return;
}
LPSTR lpNew;
LPSTR lpData[5],lpDest;
char * upNewBMP;
// 图像每行的字节数
LONG lLineBytes;
int lWidth,lHeight;
lWidth=::DIBWidth(lpDIB[0]);
lHeight=::DIBHeight(lpDIB[0]);
// 计算图像每行的字节数
lLineBytes = WIDTHBYTES(lWidth * 8);//*PictureBits);
m_hNewDIB = ::GlobalAlloc(GHND,lWidth*lHeight+*(LPDWORD)lpDIB[0] + ::PaletteSize(lpDIB[0]));
upNewBMP=( char * )::GlobalLock(m_hNewDIB);
memcpy( upNewBMP,lpDIB[0], (lpDIBBits[0]-lpDIB[0])*8 );
::GlobalUnlock(m_hNewDIB);
lpNew=::FindDIBBits(upNewBMP);
// 更改光标形状
BeginWaitCursor();
// 循环控制变量
int y;
int x;
// 临时变量
double dTmpOne;
double dTmpTwo;
// 傅立叶变换竖直方向点数
int nTransHeight ; // 傅立叶变换水平方向点数
int nTransWidth ;
// 计算进行傅立叶变换的点数 (2的整数次幂)
dTmpOne = log(lWidth)/log(2);
dTmpTwo = ceil(dTmpOne) ;
dTmpTwo = pow(2,dTmpTwo) ;
nTransWidth = (int) dTmpTwo ;
// 计算进行傅立叶变换的点数 (2的整数次幂)
dTmpOne = log(lHeight)/log(2);
dTmpTwo = ceil(dTmpOne) ;
dTmpTwo = pow(2,dTmpTwo) ;
nTransHeight = (int) dTmpTwo ; // 计算图象数据存储每行需要的字节数
// BMP文件的每行数据存储是DWORD对齐的
int nSaveWidth;
nSaveWidth = ( (lWidth << 3) + 31)/32 * 4 ;
// 图象象素值
unsigned char unchValue; complex<double> *TD = new complex<double>[nTransWidth * nTransHeight];
complex<double> *FD = new complex<double>[nTransWidth * nTransHeight];
complex<double> *TD1 = new complex<double>[nTransWidth * nTransHeight];
complex<double> *FD1 = new complex<double>[nTransWidth * nTransHeight];
complex<double> *TD3 = new complex<double>[nTransWidth * nTransHeight];
// 初始化
// 图象数据的宽和高不一定是2的整数次幂,所以pCTData
// 有一部分数据需要补0
for(y=0; y<nTransHeight; y++)
{
for(x=0; x<nTransWidth; x++)
{
TD[y*nTransWidth + x]=complex<double>(0,0);
TD1[y*nTransWidth + x]=complex<double>(0,0);
}
} // 把图象数据传给pCTData
for(y=0; y<lHeight; y++)
{
for(x=0; x<lWidth; x++)
{
unchValue = lpDIBBits[0][y*nSaveWidth +x];
TD[y*nTransWidth + x]=complex<double>(unchValue,0);
unchValue = lpDIBBits[0][y*nSaveWidth +x];
TD1[y*nTransWidth + x]=complex<double>(unchValue,0);
}
} // 傅立叶正变换
DIBFFT_2D(TD, lWidth, lHeight, FD) ;
// 傅立叶正变换
DIBFFT_2D(TD1, lWidth, lHeight, FD1) ;
// 中间变量
double dTemp;
// 进行付立叶变换的宽度和高度(2的整数次方)
LONG w;
LONG h;
int wp;
int hp;
// 赋初值
w = 1;
h = 1;
wp = 0;
hp = 0;
// 计算进行付立叶变换的宽度和高度(2的整数次方)
while(w * 2 <= lWidth)
{
w *= 2;
wp++;
}
while(h * 2 <= lHeight)
{
h *= 2;
hp++;
}
//以下计算偏移量
CString ss;
int nDpos;
double rcps, icps, mag;
for(i = 0; i < h; i++)
{
for(j = 0; j < w; j++)
{
nDpos=j+i*w;
rcps=FD[nDpos].real()*(FD1[nDpos].real()) + FD[nDpos].imag()*(FD1[nDpos].imag());
icps=FD[nDpos].imag()*(FD1[nDpos].real()) - (FD1[nDpos].imag())*(FD[nDpos].real());
mag=sqrt(rcps*rcps+icps*icps);
if(mag==0)
{
rcps=0; icps = 0; // Just in case
}
else
{
rcps /= mag;
icps /= mag;
}
FD[nDpos]=complex<double>( rcps, icps);
}
}
IFFT_2D(FD,TD3,lWidth,lHeight);
int peakx = 0, peaky = 0; // Position of the peak on the surface
float height = 0;
float peakh = 0;
int dpos;
CString s;
for(i = 0; i < h; i++)
{
for(j = 0; j < w; j++)
{
dpos = j+i*w;
height = TD3[dpos].real();
lpData[1]=lpDIBBits[1]+lLineBytes*( i) +j; *lpData[1]=height;
if(height > peakh)
{
peakx = j; peaky = i;
peakh = height;
}
}
}
//for (i = 0; i <lHeight; i ++)
{
// lpData[1]=lpDIBBits[1]+lLineBytes*(lHeight - 1 - i) + peakx;
// *lpData[1]=0;
}
s.Format("%d ,%d ,%f",peakx,peaky,peakh);
AfxMessageBox(s);
for(i=0;i<nDocCount;i++)
::GlobalUnlock(hDIB[i]);
// ((CMainFrame *)m_pMainWnd)->CreateBMP(m_hNewDIB);
delete TD,FD,TD1,FD1,TD3;
}
*/