⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wvltdoc.cpp

📁 本程序基于Visual C++6.0环境编写
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}

void CWvltDoc::OnJiaquanFusion() 
{
	// TODO: Add your command handler code here
		//读取数字图像的文件头,获取图像的属性参数
	LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
	LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
	unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
	unsigned long biHeight = lpBitmapInfoHeader->biHeight;
	unsigned long biWidth = lpBitmapInfoHeader->biWidth;
	//unsigned long biAlign = (biWidth*3+3)/4 *4;
     unsigned long biAlign = (biWidth)/4 *4;
	unsigned long bmSize = biHeight * biAlign;
	//定义图像的内存数据空间指针
	short **pData, **pDataFusion;
	CString cstrFileName = m_strFileFusion;
	//图像矩阵的坐标与像素数据
	int x, y, cur;
//	int tempR, tempG, tempB;
	//分配图像的数据空间
	pData = new short * [biHeight];
	pDataFusion = new short * [biHeight];
	for(int i = 0; i < biWidth; i ++)
	{
		pDataFusion[i] = new short [biWidth];
		pData[i] = new short [biWidth];
	}
	//从设备的显示缓存中获取原始图像的数据
	for(y = 0; y < (int) biHeight; y ++)
	{
		for(x = 0; x < (int) biWidth; x ++)
		{
		
               cur = y * biAlign + x;
	
          pData[biHeight - 1 - y][x] =lpData[cur];
		}
	}
	//释放设备占用的显示缓存
	//m_pBitmap = NULL;
	//打开另外一幅用于融合的图像文件
	MessageBoxA(NULL,_T("请在WvltDip\\Fusion目录中打开另外一幅图像,进行加权图像融合"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
	while(!abs((int)strcmp(m_strFileFusion, cstrFileName)))
	{
		CFileDialog dlg( TRUE,NULL,NULL,
	                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
	                 _T("Bitmap (*.BMP)|*.BMP|"));
		if( dlg.DoModal()==IDOK )
			cstrFileName = dlg.GetPathName();
		//如果文件重名,提示重新打开文件
		if(!abs((int)strcmp(m_strFileFusion, cstrFileName))) 
			MessageBoxA(NULL,_T("文件"+m_strFileFusion+"已打开,请打开该目录中另外一个文件"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
		else
			MessageBoxA(NULL,_T("用于图像融合的文件是:\n"+m_strFileFusion+"\n"+cstrFileName),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
	}
 

    CWvltApp* App =(CWvltApp*) AfxGetApp();
	
    
    CFrameWnd* pNewFrame1 = App->m_pImageTemplate1->CreateNewFrame(this, NULL);


	App->m_pImageTemplate1->InitialUpdateFrame(pNewFrame1, this);

	// Tile the two MDI children windows within the MDI frame window.
	ASSERT_KINDOF(CMDIChildWnd, pNewFrame1);
	CMDIFrameWnd* pMDIFrameWnd1 = ((CMDIChildWnd*)pNewFrame1)->GetMDIFrame();
	ASSERT(pMDIFrameWnd1 != NULL);
	pMDIFrameWnd1->MDICascade(); 

	//读取位图数据,载入显示缓存中
	 ReadBitmap(cstrFileName, m_pTransfered1);
	 ReadBitmap(cstrFileName, m_pTransfered);
	//显示新打开的图像

	UpdateAllViews(NULL);
	
	//读取另外一幅图像的数据
	lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pTransfered+14);
	lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pTransfered;
	unsigned char *lpImgData = m_pTransfered + lpBitmapFileHeader->bfOffBits;
	//从设备的显示缓存中获取原始图像的数据
	for(y = 0; y < biHeight; y ++)
	{
		for (x = 0; x < biWidth; x++)
		{
		   cur = y * biAlign + x;
	    	pDataFusion[biHeight - 1 - y][x] =lpImgData[cur];
		}
	}
	//清空显示缓存,并重新分配显示缓存
	m_pTransfered = NULL;
	m_pTransfered=(unsigned char*) malloc (bmSize);
	if(m_pTransfered==NULL)
		return;
	//创建用于图像融合的Diproc类
	//CDiproc *pDIP;
//	pDIP->DIP_ImageFusion(pData, pDataFusion, biHeight, biWidth);
  // 进行空域融合处理
   for(y = 0; y < biHeight; y ++)
	{
		for (x = 0; x < biWidth; x++)
		{
	
             pDataFusion[biHeight - 1 - y][x] =0.5*pDataFusion[biHeight - 1 - y][x]+0.5*pData[biHeight - 1 - y][x];
		}
	}
      
    //将图像数据放入显示缓存中
	for(y=0; y<(int)biHeight; y++)
	{
		for(x=0; x<(int)biWidth; x++)
		{
			//cur= y*biAlign+3*x;		//current pixel	
               cur= y*biAlign+x;
			m_pTransfered[cur]	= (unsigned char)pDataFusion[biHeight - 1- y][x];
		
		}
	}
	//显示图像复原的结果*/
	UpdateAllViews(NULL);
	//删除临时的数据内存空间
//	delete pData;
//	delete pDataFusion;	
	
}

//DEL void CWvltDoc::OnBiaozcEva() 
//DEL {
//DEL 	// TODO: Add your command handler code here
//DEL     // TODO: Add your command handler code here
//DEL     LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
//DEL 	LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
//DEL 	unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
//DEL 	unsigned long biHeight = lpBitmapInfoHeader->biHeight;
//DEL 	unsigned long biWidth = lpBitmapInfoHeader->biWidth;
//DEL 	//unsigned long biAlign = (biWidth*3+3)/4 *4;
//DEL      unsigned long biAlign = (biWidth)/4 *4;
//DEL 	unsigned long bmSize = biHeight * biAlign;
//DEL 	//定义图像的内存数据空间指针
//DEL 	short **pData, **pDataFusion;
//DEL //	CString cstrFileName = m_strFileFusion;
//DEL 	//图像矩阵的坐标与像素数据
//DEL 	int x, y, cur;
//DEL //	int tempR, tempG, tempB;
//DEL 	//分配图像的数据空间
//DEL 	pData = new short * [biHeight];
//DEL 	pDataFusion = new short * [biHeight];
//DEL 	for(int i = 0; i < biWidth; i ++)
//DEL 	{
//DEL 		pDataFusion[i] = new short [biWidth];
//DEL 		pData[i] = new short [biWidth];
//DEL 	}
//DEL 	//从设备的显示缓存中获取原始图像的数据
//DEL 	for(y = 0; y < (int) biHeight; y ++)
//DEL 	{
//DEL 		for(x = 0; x < (int) biWidth; x ++)
//DEL 		{
//DEL 			//cur = y * biAlign + 3 * x;
//DEL                cur = y * biAlign + x;
//DEL 		//	tempB = lpData[cur];
//DEL 		//	tempG = lpData[cur + 1];
//DEL 		//	tempR = lpData[cur + 2];
//DEL 		//	pData[biHeight - 1 - y][x] = 0.3 * tempR + 0.59 * tempG + 0.11 * tempB;
//DEL           pData[biHeight - 1 - y][x] =lpData[cur];
//DEL 		}
//DEL 	}
//DEL 	//释放设备占用的显示缓存
//DEL 	//m_pBitmap = NULL;
//DEL 	//打开另外一幅用于融合的图像文件
//DEL /*	MessageBoxA(NULL,_T("请在WvltDip\\Fusion目录中打开另外一幅图像,进行加权图像融合"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
//DEL 	while(!abs((int)strcmp(m_strFileFusion, cstrFileName)))
//DEL 	{
//DEL 		CFileDialog dlg( TRUE,NULL,NULL,
//DEL 	                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
//DEL 	                 _T("Bitmap (*.BMP)|*.BMP|"));
//DEL 		if( dlg.DoModal()==IDOK )
//DEL 			cstrFileName = dlg.GetPathName();
//DEL 		//如果文件重名,提示重新打开文件
//DEL 		if(!abs((int)strcmp(m_strFileFusion, cstrFileName))) 
//DEL 			MessageBoxA(NULL,_T("文件"+m_strFileFusion+"已打开,请打开该目录中另外一个文件"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
//DEL 		else
//DEL 			MessageBoxA(NULL,_T("用于图像融合的文件是:\n"+m_strFileFusion+"\n"+cstrFileName),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
//DEL 	}
//DEL 	//读取位图数据,载入显示缓存中
//DEL 	ReadBitmap(cstrFileName, m_pTransfered);
//DEL 	//显示新打开的图像
//DEL 	UpdateAllViews(NULL);
//DEL 	//读取另外一幅图像的数据
//DEL 	lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pTransfered+14);
//DEL 	lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pTransfered;
//DEL 	unsigned char *lpImgData = m_pTransfered + lpBitmapFileHeader->bfOffBits;
//DEL 	//从设备的显示缓存中获取原始图像的数据
//DEL 	for(y = 0; y < biHeight; y ++)
//DEL 	{
//DEL 		for (x = 0; x < biWidth; x++)
//DEL 		{
//DEL 			//cur = y * biAlign + 3 * x;
//DEL              cur = y * biAlign + x;
//DEL 			//tempB = lpImgData[cur];
//DEL 			//tempG = lpImgData[cur + 1];
//DEL 			//tempR = lpImgData[cur + 2];
//DEL 			//pDataFusion[biHeight - 1 - y][x] = 0.3 * tempR + 0.59 * tempG + 0.11 * tempB;
//DEL 
//DEL              pDataFusion[biHeight - 1 - y][x] =lpImgData[cur];
//DEL 		}
//DEL 	}
//DEL 	//清空显示缓存,并重新分配显示缓存
//DEL 	m_pTransfered = NULL;
//DEL 	m_pTransfered=(unsigned char*) malloc (bmSize);
//DEL 	if(m_pTransfered==NULL)
//DEL 		return;
//DEL 	//创建用于图像融合的Diproc类
//DEL 	//CDiproc *pDIP;
//DEL //	pDIP->DIP_ImageFusion(pData, pDataFusion, biHeight, biWidth);*/
//DEL   // 进行标准差处理
//DEL  unsigned long SUM,AVE,SUM1,AVE1;
//DEL 
//DEL      
//DEL // 将结果进行输出
//DEL //	CString CView;
//DEL //	CView.Format("图像的标准差为:%d",AVE1);
//DEL //	MessageBox(NULL,CView, "计算结果" ,	MB_ICONINFORMATION | MB_OK);
//DEL 
//DEL 
//DEL 
//DEL 
//DEL 	
//DEL 	
//DEL }

void CWvltDoc::OnQudaFusion() 
{
	// TODO: Add your command handler code here
		//读取数字图像的文件头,获取图像的属性参数
	LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
	LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
	unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
	unsigned long biHeight = lpBitmapInfoHeader->biHeight;
	unsigned long biWidth = lpBitmapInfoHeader->biWidth;
	//unsigned long biAlign = (biWidth*3+3)/4 *4;
     unsigned long biAlign = (biWidth)/4 *4;
	unsigned long bmSize = biHeight * biAlign;
	//定义图像的内存数据空间指针
	short **pData, **pDataFusion;
	CString cstrFileName = m_strFileFusion;
	//图像矩阵的坐标与像素数据
	int x, y, cur;
//	int tempR, tempG, tempB;
	//分配图像的数据空间
	pData = new short * [biHeight];
	pDataFusion = new short * [biHeight];
	for(int i = 0; i < biWidth; i ++)
	{
		pDataFusion[i] = new short [biWidth];
		pData[i] = new short [biWidth];
	}
	//从设备的显示缓存中获取原始图像的数据
	for(y = 0; y < (int) biHeight; y ++)
	{
		for(x = 0; x < (int) biWidth; x ++)
		{
		
               cur = y * biAlign + x;
	
          pData[biHeight - 1 - y][x] =lpData[cur];
		}
	}
	//释放设备占用的显示缓存
	//m_pBitmap = NULL;
	//打开另外一幅用于融合的图像文件
	MessageBoxA(NULL,_T("请在WvltDip\\Fusion目录中打开另外一幅图像,进行加权图像融合"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
	while(!abs((int)strcmp(m_strFileFusion, cstrFileName)))
	{
		CFileDialog dlg( TRUE,NULL,NULL,
	                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
	                 _T("Bitmap (*.BMP)|*.BMP|"));
		if( dlg.DoModal()==IDOK )
			cstrFileName = dlg.GetPathName();
		//如果文件重名,提示重新打开文件
		if(!abs((int)strcmp(m_strFileFusion, cstrFileName))) 
			MessageBoxA(NULL,_T("文件"+m_strFileFusion+"已打开,请打开该目录中另外一个文件"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
		else
			MessageBoxA(NULL,_T("用于图像融合的文件是:\n"+m_strFileFusion+"\n"+cstrFileName),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
	}
 

    CWvltApp* App =(CWvltApp*) AfxGetApp();
	
    
    CFrameWnd* pNewFrame1 = App->m_pImageTemplate1->CreateNewFrame(this, NULL);


	App->m_pImageTemplate1->InitialUpdateFrame(pNewFrame1, this);

	// Tile the two MDI children windows within the MDI frame window.
	ASSERT_KINDOF(CMDIChildWnd, pNewFrame1);
	CMDIFrameWnd* pMDIFrameWnd1 = ((CMDIChildWnd*)pNewFrame1)->GetMDIFrame();
	ASSERT(pMDIFrameWnd1 != NULL);
	pMDIFrameWnd1->MDICascade(); 

	//读取位图数据,载入显示缓存中
	 ReadBitmap(cstrFileName, m_pTransfered1);
	 ReadBitmap(cstrFileName, m_pTransfered);
	//显示新打开的图像

	UpdateAllViews(NULL);
	
	//读取另外一幅图像的数据
	lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pTransfered+14);
	lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pTransfered;
	unsigned char *lpImgData = m_pTransfered + lpBitmapFileHeader->bfOffBits;
	//从设备的显示缓存中获取原始图像的数据
	for(y = 0; y < biHeight; y ++)
	{
		for (x = 0; x < biWidth; x++)
		{
		   cur = y * biAlign + x;
	    	pDataFusion[biHeight - 1 - y][x] =lpImgData[cur];
		}
	}
	//清空显示缓存,并重新分配显示缓存
	m_pTransfered = NULL;
	m_pTransfered=(unsigned char*) malloc (bmSize);
	if(m_pTransfered==NULL)
		return;
	//创建用于图像融合的Diproc类
	//CDiproc *pDIP;
//	pDIP->DIP_ImageFusion(pData, pDataFusion, biHeight, biWidth);
  // 进行空域融合处理
   for(y = 0; y < biHeight; y ++)
	{
		for (x = 0; x < biWidth; x++)
		{
		    if(pDataFusion[biHeight - 1 - y][x]<pData[biHeight - 1 - y][x])
             pDataFusion[biHeight - 1 - y][x]=pData[biHeight - 1 - y][x];
             
		}
	}
      
    //将图像数据放入显示缓存中
	for(y=0; y<(int)biHeight; y++)
	{
		for(x=0; x<(int)biWidth; x++)
		{
			//cur= y*biAlign+3*x;		//current pixel	
               cur= y*biAlign+x;
			m_pTransfered[cur]	= (unsigned char)pDataFusion[biHeight - 1- y][x];
		
		}
	}
	//显示图像复原的结果
	UpdateAllViews(NULL);
	//删除临时的数据内存空间
//	delete pData;
//	delete pDataFusion;	
	
}

void CWvltDoc::OnQuxiaoFusion() 
{
	// TODO: Add your command handler code here
   		//读取数字图像的文件头,获取图像的属性参数
	LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
	LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
	unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
	unsigned long biHeight = lpBitmapInfoHeader->biHeight;
	unsigned long biWidth = lpBitmapInfoHeader->biWidth;
	//unsigned long biAlign = (biWidth*3+3)/4 *4;
     unsigned long biAlign = (biWidth)/4 *4;
	unsigned long bmSize = biHeight * biAlign;
	//定义图像的内存数据空间指针
	short **pData, **pDataFusion;
	CString cstrFileName = m_strFileFusion;
	//图像矩阵的坐标与像素数据
	int x, y, cur;
//	int tempR, tempG, tempB;
	//分配图像的数据空间
	pData = new short * [biHeight];
	pDataFusion = new short * [biHeight];
	for(int i = 0; i < biWidth; i ++)
	{
		pDataFusion[i] = new short [biWidth];
		pData[i] = new short [biWidth];
	}
	//从设备的显示缓存中获取原始图像的数据
	for(y = 0; y < (int) biHeight; y ++)
	{
		for(x = 0; x < (int) biWidth; x ++)
		{
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -