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

📄 main.cpp

📁 基于小波的图像配准
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//=============================================================
//     create the output image with the best transform
	   *angleC=(*angleC)*3.14159265359/180;
       c_resample(image_in,image_out,img_width,img_height,
		        -*xC,-*yC,-*angleC);       imgWrite(tfPtr,0,0,img_width,img_height,image_out);
       free(image_in);
	   free(image_re);
	   free(image_out);
       free(inLL_level1); free(inLH_level1); free(inHL_level1); free(inHH_level1);
	   free(reLL_level1); free(reLH_level1); free(reHL_level1); free(reHH_level1);
       free(inLL_level2); free(inLH_level2); free(inHL_level2); free(inHH_level2);
	   free(reLL_level2); free(reLH_level2); free(reHL_level2); free(reHH_level2);
       free(inLL_level3); free(inLH_level3); free(inHL_level3); free(inHH_level3);
	   free(reLL_level3); free(reLH_level3); free(reHL_level3); free(reHH_level3);
	   free(h_coe);

	   imgClose(infPtr);
	   imgClose(refPtr);       imgClose(tfPtr);
	   return;}


/*
//=============================================================
//     create the output image by wavelets decomposition
	unsigned char *image_LL,*image_LH,*image_HL,*image_HH;
	image_LL = (unsigned char *)malloc((img_width/2)*(img_height/2));
	image_LH = (unsigned char *)malloc((img_width/2)*(img_height/2));
	image_HL = (unsigned char *)malloc((img_width/2)*(img_height/2));
	image_HH = (unsigned char *)malloc((img_width/2)*(img_height/2));
       
	double* tmp1; unsigned char* tmp2;
	long times=20,j;
	double pixel_d;

	j = (img_width/2)*(img_height/2);
//input image first wavelet transform
	tmp1=inLL_level1;tmp2=image_LL;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

	tmp1=inLH_level1;tmp2=image_LH;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

 
	tmp1=inHL_level1;tmp2=image_HL;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect 
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }
		

	tmp1=inHH_level1;tmp2=image_HH;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

       targetfilename="in-wavelet.bmp";
	   tfPtr = imgOpen(targetfilename,&img_width,&img_height,1);
	   width=img_width/2;height=img_height/2;
//	   tfPtr = imgOpen(targetfilename,&width,&height,1);
//	   imgWrite(tfPtr,0,0,width,height,image_HL);
	   
	   imgWrite(tfPtr,0,height,width,height,image_LL);
	   imgWrite(tfPtr,width,height,width,height,image_HL);
	   imgWrite(tfPtr,0,0,width,height,image_LH);	   
	   imgWrite(tfPtr,width,0,width,height,image_HH);
	   imgClose(tfPtr);

//refer image first wavelet transform
	tmp1=reLL_level1;tmp2=image_LL;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

	tmp1=reLH_level1;tmp2=image_LH;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

 
	tmp1=reHL_level1;tmp2=image_HL;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect 
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }
		

	tmp1=reHH_level1;tmp2=image_HH;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

       targetfilename="re-wavelet.bmp";
	   tfPtr = imgOpen(targetfilename,&img_width,&img_height,1);
	   width=img_width/2;height=img_height/2;
//	   tfPtr = imgOpen(targetfilename,&width,&height,1);
//	   imgWrite(tfPtr,0,0,width,height,image_HL);
	   
	   imgWrite(tfPtr,0,height,width,height,image_LL);
	   imgWrite(tfPtr,width,height,width,height,image_HL);
	   imgWrite(tfPtr,0,0,width,height,image_LH);	   
	   imgWrite(tfPtr,width,0,width,height,image_HH);
	   imgClose(tfPtr);

//=========================================================================
//     second level wavelet transform, input data is LL

	   unsigned char *image_LL1,*image_LH1,*image_HL1,*image_HH1;
	   image_LL1 = (unsigned char *)malloc((img_width/4)*(img_height/4));
	   image_LH1 = (unsigned char *)malloc((img_width/4)*(img_height/4));
	   image_HL1 = (unsigned char *)malloc((img_width/4)*(img_height/4));
	   image_HH1 = (unsigned char *)malloc((img_width/4)*(img_height/4));
       
//=============================================================
//     create the output image by wavelets decomposition

	j = (img_width/4)*(img_height/4);

//input image second wavelet transform
	tmp1=inLL_level2;tmp2=image_LL1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

	tmp1=inLH_level2;tmp2=image_LH1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

 
	tmp1=inHL_level2;tmp2=image_HL1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect 
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }
		

	tmp1=inHH_level2;tmp2=image_HH1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }
	   
	   targetfilename="in-wavelet1.bmp";
	   tfPtr = imgOpen(targetfilename,&width,&height,1);
       
//	   tfPtr = imgOpen(targetfilename,&width,&height,1);
//	   imgWrite(tfPtr,0,0,width,height,image_HL);

	   width=img_width/4;height=img_height/4;
	   imgWrite(tfPtr,0,height,width,height,image_LL1);
	   imgWrite(tfPtr,width,height,width,height,image_HL1);
	   imgWrite(tfPtr,0,0,width,height,image_LH1);	   
	   imgWrite(tfPtr,width,0,width,height,image_HH1);
       imgClose(infPtr);
	   imgClose(tfPtr);

//refer image second wavelet transform
	width=img_width/2;height=img_height/2;
	tmp1=reLL_level2;tmp2=image_LL1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

	tmp1=reLH_level2;tmp2=image_LH1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }

 
	tmp1=reHL_level2;tmp2=image_HL1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect 
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }
		

	tmp1=reHH_level2;tmp2=image_HH1;	
	for(i=0;i<j;i++){
			   	pixel_d = *tmp1;		
				if(pixel_d >255.) { pixel_d = 255.; }
				if(pixel_d <0. )  { pixel_d = 0.; }
				pixel_d = pixel_d*times;//enhancement for vision effect
				*tmp2 = (unsigned char)pixel_d;
				tmp1++;tmp2++;
		   
	   }
	   
	   targetfilename="re-wavelet1.bmp";
	   tfPtr = imgOpen(targetfilename,&width,&height,1);
       
//	   tfPtr = imgOpen(targetfilename,&width,&height,1);
//	   imgWrite(tfPtr,0,0,width,height,image_HL);

	   width=img_width/4;height=img_height/4;
	   imgWrite(tfPtr,0,height,width,height,image_LL1);
	   imgWrite(tfPtr,width,height,width,height,image_HL1);
	   imgWrite(tfPtr,0,0,width,height,image_LH1);	   
	   imgWrite(tfPtr,width,0,width,height,image_HH1);
	   free(image_LL); free(image_LH); free(image_HL); free(image_HH);
	   free(image_LL1); free(image_LH1); free(image_HL1); free(image_HH1);
       imgClose(infPtr);
	   imgClose(tfPtr);*/	

⌨️ 快捷键说明

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