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

📄 watermethod.cpp

📁 站长!这是DCT域的图像数字水印嵌入及提取程序!请查收!暂归入加密解密类别!
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		output1[i]=input1[i]+(*totalmean);
		output2[i]=input2[i]+(*totalmean);
	}
}

int CWatermethod::Subsamplingmethod(long int blocks,
						 unsigned short  blockheight,
						 unsigned short  blockwidth,
						 unsigned short  hb,
						 unsigned short  wb,
						 unsigned char *SourceVector1[MAXINPUTVECTORS/4],
						 unsigned char *SourceVector2[MAXINPUTVECTORS/4],
						 unsigned char *SourceVector3[MAXINPUTVECTORS/4],
						 unsigned char *SourceVector4[MAXINPUTVECTORS/4],
						 unsigned char *WmSourceVector1[MAXINPUTVECTORS/4],
						 unsigned char *WmSourceVector2[MAXINPUTVECTORS/4],
     					 unsigned char *TerminalVector1[MAXINPUTVECTORS/4],
						 unsigned char *TerminalVector2[MAXINPUTVECTORS/4],
						 unsigned char *TerminalVector3[MAXINPUTVECTORS/4],
						 unsigned char *TerminalVector4[MAXINPUTVECTORS/4],
                         int method)
 {

   long int k,l;
   unsigned short int dimension;
   int m;
   unsigned char blktime1[8][8];
   unsigned char *blocktime1[8];
   unsigned char blktime2[8][8];
   unsigned char *blocktime2[8];
   unsigned char blktime3[8][8];
   unsigned char *blocktime3[8];
   unsigned char blktime4[8][8];
   unsigned char *blocktime4[8];
   unsigned char wmblktime[4][4];
   unsigned char *wmblocktime[4];
   unsigned char wmblktime1[4][4];
   unsigned char *wmblocktime1[4];
   unsigned char embedimageblktime1[8][8];
   unsigned char *embedimageblocktime1[8];
   unsigned char embedimageblktime2[8][8];
   unsigned char *embedimageblocktime2[8];
   unsigned char embedimageblktime3[8][8];
   unsigned char *embedimageblocktime3[8];
   unsigned char embedimageblktime4[8][8];
   unsigned char *embedimageblocktime4[8];
   double blkfreq1[8][8];
   double *blockfreq1[8];
   double embedimageblkfreq1[8][8];
   double *embedimageblockfreq1[8];
   double blkfreq2[8][8];
   double *blockfreq2[8];
   double embedimageblkfreq2[8][8];
   double *embedimageblockfreq2[8];
   double blkfreq3[8][8];
   double *blockfreq3[8];
   double embedimageblkfreq3[8][8];
   double *embedimageblockfreq3[8];
   double blkfreq4[8][8];
   double *blockfreq4[8];
   double embedimageblkfreq4[8][8];
   double *embedimageblockfreq4[8];
   for(l=0;l<MAXBLOCKHEIGHT;l++)
   {
	   blocktime1[l]=blktime1[l];
	   blockfreq1[l]=blkfreq1[l];
	   embedimageblocktime1[l]=embedimageblktime1[l];
	   embedimageblockfreq1[l]=embedimageblkfreq1[l];
	   blocktime2[l]=blktime2[l];
	   blockfreq2[l]=blkfreq2[l];
	   embedimageblocktime2[l]=embedimageblktime2[l];
	   embedimageblockfreq2[l]=embedimageblkfreq2[l];
	   blocktime3[l]=blktime3[l];
	   blockfreq3[l]=blkfreq3[l];
	   embedimageblocktime3[l]=embedimageblktime3[l];
	   embedimageblockfreq3[l]=embedimageblkfreq3[l];
	   blocktime4[l]=blktime4[l];
	   blockfreq4[l]=blkfreq4[l];
	   embedimageblocktime4[l]=embedimageblktime4[l];
	   embedimageblockfreq4[l]=embedimageblkfreq4[l];
   }
   for(l=0;l<4;l++)
   {
	   wmblocktime[l]=wmblktime[l];
	   wmblocktime1[l]=wmblktime1[l];
   }
   //the arrays
   dimension=blockwidth*blockheight;
   if(blocks>MAXENCODEVECTORS)
   	  return -1;
   	for(m=0;m<32*32;m++)
	{
		//Transmit one block data of the original image to the blocktime block of the original image 
		for(l=0;l<blockheight;l++)
		  for(k=0;k<blockwidth;k++) 	
		  {
		    blktime1[k][l]=SourceVector1[m][k+l*blockwidth];
		 	blktime2[k][l]=SourceVector2[m][k+l*blockwidth];
		 	blktime3[k][l]=SourceVector3[m][k+l*blockwidth];
		 	blktime4[k][l]=SourceVector4[m][k+l*blockwidth];
		  }
		//Transmit one block data of the original watermark image to the blocktime block of the original watermark image
	  for(l=0; l<4;l++)
		  for(k=0; k<4; k++)	
		  {
    		  wmblktime[k][l]=WmSourceVector1[m][k+l*4];
			  wmblktime1[k][l]=WmSourceVector2[m][k+l*4];
		  }
		  //DCT is use for one sub block of the original image
		DCT(blocktime1,blockfreq1,blockwidth,blockheight);
		DCT(blocktime2,blockfreq2,blockwidth,blockheight);
		DCT(blocktime3,blockfreq3,blockwidth,blockheight);
		DCT(blocktime4,blockfreq4,blockwidth,blockheight);

		//Embed the watermark into the original image
      if(method==1)
        samplingembed(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,embedimageblockfreq1,embedimageblockfreq2,
	    embedimageblockfreq3,embedimageblockfreq4,blockwidth,blockheight);
      if(method==2)
        DMBsamplingembed(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,wmblocktime1,embedimageblockfreq1,embedimageblockfreq2,
	    embedimageblockfreq3,embedimageblockfreq4,blockwidth,blockheight);
		//IDCT is use for one sub block 
		IDCT(embedimageblockfreq1,embedimageblocktime1,blockwidth,blockheight);
		IDCT(embedimageblockfreq2,embedimageblocktime2,blockwidth,blockheight);
		IDCT(embedimageblockfreq3,embedimageblocktime3,blockwidth,blockheight);
		IDCT(embedimageblockfreq4,embedimageblocktime4,blockwidth,blockheight);
		//Transmit the the data after DCT and IDCT operation to store memory
		for(l=0; l<blockheight;l++)
		  for(k=0; k<blockwidth; k++)
		  {
			TerminalVector1[m][k+l*blockwidth]=embedimageblocktime1[k][l];
			TerminalVector2[m][k+l*blockwidth]=embedimageblocktime2[k][l];
			TerminalVector3[m][k+l*blockwidth]=embedimageblocktime3[k][l];
			TerminalVector4[m][k+l*blockwidth]=embedimageblocktime4[k][l];
		  }
	}
    return 0;
}

int CWatermethod::ExtractSubsamplingmethod(long int blocks,
	                              unsigned short blockwidth,
								  unsigned short blockheight,
								  unsigned short wb,
								  unsigned short hb,
								  unsigned short wmblockheight,
								  unsigned short wmblockwidth,
								  unsigned char *SourceVector1[MAXINPUTVECTORS/4],
								  unsigned char *SourceVector2[MAXINPUTVECTORS/4],
								  unsigned char *SourceVector3[MAXINPUTVECTORS/4],
								  unsigned char *SourceVector4[MAXINPUTVECTORS/4],
								  unsigned char *pp1[MAXINPUTVECTORS/4],
								  unsigned char *pp2[MAXINPUTVECTORS/4],
                                   int method)
 {
   long int k,l;
   unsigned short int dimension;
   int m;
   unsigned char blktime1[8][8];
   unsigned char *blocktime1[8];
   unsigned char blktime2[8][8];
   unsigned char *blocktime2[8];
   unsigned char blktime3[8][8];
   unsigned char *blocktime3[8];
   unsigned char blktime4[8][8];
   unsigned char *blocktime4[8];
   double blkfreq1[8][8];
   double *blockfreq1[8];
   double blkfreq2[8][8];
   double *blockfreq2[8];
   double blkfreq3[8][8];
   double *blockfreq3[8];
   double blkfreq4[8][8];
   double *blockfreq4[8];
   unsigned char wmblktime[4][4];
   unsigned char *wmblocktime[4];
   unsigned char wmblktime1[4][4];
   unsigned char *wmblocktime1[4];
 
   for(l=0;l<MAXBLOCKHEIGHT;l++)
   {
	   blocktime1[l]=blktime1[l];
	   blockfreq1[l]=blkfreq1[l];
	   blocktime2[l]=blktime2[l];
	   blockfreq2[l]=blkfreq2[l];
	   blocktime3[l]=blktime3[l];
	   blockfreq3[l]=blkfreq3[l];
	   blocktime4[l]=blktime4[l];
	   blockfreq4[l]=blkfreq4[l];
   }
   for(l=0;l<wmblockheight;l++)
   {
	   wmblocktime[l]=wmblktime[l];
	   wmblocktime1[l]=wmblktime1[l];
   }
   dimension=blockwidth*blockheight;
   if(blocks>MAXENCODEVECTORS)
   	  return -1;
   	for(m=0;m<32*32;m++)
	{
		//Transmit one block data of the original image to the blocktime block of the original image 
		for(l=0;l<blockheight;l++)
		  for(k=0;k<blockwidth;k++) 	
		  {
		    blktime1[k][l]=SourceVector1[m][k+l*blockwidth];
		 	blktime2[k][l]=SourceVector2[m][k+l*blockwidth];
		 	blktime3[k][l]=SourceVector3[m][k+l*blockwidth];
		 	blktime4[k][l]=SourceVector4[m][k+l*blockwidth];
		  }
		  //DCT is use for one sub block of the original image
		DCT(blocktime1,blockfreq1,blockwidth,blockheight);
		DCT(blocktime2,blockfreq2,blockwidth,blockheight);
		DCT(blocktime3,blockfreq3,blockwidth,blockheight);
		DCT(blocktime4,blockfreq4,blockwidth,blockheight);
      if(method==1)
        samplingextract(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,blockwidth,blockheight);
      if(method==2)
        DMBsamplingextract(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,wmblocktime1,blockwidth,blockheight);
		//Transmit one block data of the original watermark image to the blocktime block of the original watermark image
	    for(l=0; l<wmblockheight;l++)
		  for(k=0; k<wmblockwidth;k++)	
		  {
			  pp1[m][k+l*4]=wmblktime[k][l];
			  pp2[m][k+l*4]=wmblktime1[k][l];
		  }
	}
    return 0;
}
/*
int CWatermethod::Subsamplingmethod1(long int blocks,
						 unsigned short  blockheight,
						 unsigned short  blockwidth,
						 unsigned short  hb,
						 unsigned short  wb,
						 unsigned char *SourceVector1[MAXINPUTVECTORS/4],
						 char *SourceVector2[MAXINPUTVECTORS/4],
						 char *SourceVector3[MAXINPUTVECTORS/4],
						 unsigned char *SourceVector4[MAXINPUTVECTORS/4],
						 unsigned char *WmSourceVector1[MAXINPUTVECTORS/4],
						 unsigned char *WmSourceVector2[MAXINPUTVECTORS/4],
     					 unsigned char *TerminalVector1[MAXINPUTVECTORS/4],
						 char *TerminalVector2[MAXINPUTVECTORS/4],
						 char *TerminalVector3[MAXINPUTVECTORS/4],
						 unsigned char *TerminalVector4[MAXINPUTVECTORS/4],
                         int method)
 {

   long int k,l;
   unsigned short int dimension;
   int m;
   unsigned char blktime1[8][8];
   unsigned char *blocktime1[8];
   char blktime2[8][8];
   char *blocktime2[8];
   char blktime3[8][8];
   char *blocktime3[8];
   unsigned char blktime4[8][8];
   unsigned char *blocktime4[8];
   unsigned char wmblktime[4][4];
   unsigned char *wmblocktime[4];
   unsigned char wmblktime1[4][4];
   unsigned char *wmblocktime1[4];
   unsigned char embedimageblktime1[8][8];
   unsigned char *embedimageblocktime1[8];
   char embedimageblktime2[8][8];
   char *embedimageblocktime2[8];
   char embedimageblktime3[8][8];
   char *embedimageblocktime3[8];
   unsigned char embedimageblktime4[8][8];
   unsigned char *embedimageblocktime4[8];
   double blkfreq1[8][8];
   double *blockfreq1[8];
   double embedimageblkfreq1[8][8];
   double *embedimageblockfreq1[8];
   double blkfreq2[8][8];
   double *blockfreq2[8];
   double embedimageblkfreq2[8][8];
   double *embedimageblockfreq2[8];
   double blkfreq3[8][8];
   double *blockfreq3[8];
   double embedimageblkfreq3[8][8];
   double *embedimageblockfreq3[8];
   double blkfreq4[8][8];
   double *blockfreq4[8];
   double embedimageblkfreq4[8][8];
   double *embedimageblockfreq4[8];
   for(l=0;l<MAXBLOCKHEIGHT;l++)
   {
	   blocktime1[l]=blktime1[l];
	   blockfreq1[l]=blkfreq1[l];
	   embedimageblocktime1[l]=embedimageblktime1[l];
	   embedimageblockfreq1[l]=embedimageblkfreq1[l];
	   blocktime2[l]=blktime2[l];
	   blockfreq2[l]=blkfreq2[l];
	   embedimageblocktime2[l]=embedimageblktime2[l];
	   embedimageblockfreq2[l]=embedimageblkfreq2[l];
	   blocktime3[l]=blktime3[l];
	   blockfreq3[l]=blkfreq3[l];
	   embedimageblocktime3[l]=embedimageblktime3[l];
	   embedimageblockfreq3[l]=embedimageblkfreq3[l];
	   blocktime4[l]=blktime4[l];
	   blockfreq4[l]=blkfreq4[l];
	   embedimageblocktime4[l]=embedimageblktime4[l];
	   embedimageblockfreq4[l]=embedimageblkfreq4[l];
   }
   for(l=0;l<4;l++)
   {
	   wmblocktime[l]=wmblktime[l];
	   wmblocktime1[l]=wmblktime1[l];
   }
   //the arrays
   dimension=blockwidth*blockheight;
   if(blocks>MAXENCODEVECTORS)
   	  return -1;
   	for(m=0;m<32*32;m++)
	{
		//Transmit one block data of the original image to the blocktime block of the original image 
		for(l=0;l<blockheight;l++)
		  for(k=0;k<blockwidth;k++) 	
		  {
		    blktime1[k][l]=SourceVector1[m][k+l*blockwidth];
		 	blktime2[k][l]=SourceVector2[m][k+l*blockwidth];
		 	blktime3[k][l]=SourceVector3[m][k+l*blockwidth];
		 	blktime4[k][l]=SourceVector4[m][k+l*blockwidth];
		  }
		//Transmit one block data of the original watermark image to the blocktime block of the original watermark image
	  for(l=0; l<4;l++)
		  for(k=0; k<4; k++)	
		  {
			  wmblktime[k][l]=WmSourceVector1[m][k+l*4];
              if(WmSourceVector2!=0)
			  wmblktime1[k][l]=WmSourceVector2[m][k+l*4];
		  }
		  //DCT is use for one sub block of the original image
		DCT(blocktime1,blockfreq1,blockwidth,blockheight);
		DCT1(blocktime2,blockfreq2,blockwidth,blockheight);
		DCT1(blocktime3,blockfreq3,blockwidth,blockheight);
		DCT(blocktime4,blockfreq4,blockwidth,blockheight);

		//Embed the watermark into the original image
      if(method==1)
        samplingembed(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,embedimageblockfreq1,embedimageblockfreq2,
	    embedimageblockfreq3,embedimageblockfreq4,blockwidth,blockheight);
      if(method==2)
        DMBsamplingembed(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,wmblocktime1,embedimageblockfreq1,embedimageblockfreq2,
	    embedimageblockfreq3,embedimageblockfreq4,blockwidth,blockheight);
		//IDCT is use for one sub block 
		IDCT(embedimageblockfreq1,embedimageblocktime1,blockwidth,blockheight);
		IDCT1(embedimageblockfreq2,embedimageblocktime2,blockwidth,blockheight);
		IDCT1(embedimageblockfreq3,embedimageblocktime3,blockwidth,blockheight);
		IDCT(embedimageblockfreq4,embedimageblocktime4,blockwidth,blockheight);
		//Transmit the the data after DCT and IDCT operation to store memory
		for(l=0; l<blockheight;l++)
		  for(k=0; k<blockwidth; k++)
		  {
			TerminalVector1[m][k+l*blockwidth]=embedimageblocktime1[k][l];
			TerminalVector2[m][k+l*blockwidth]=embedimageblocktime2[k][l];
			TerminalVector3[m][k+l*blockwidth]=embedimageblocktime3[k][l];
			TerminalVector4[m][k+l*blockwidth]=embedimageblocktime4[k][l];
		  }
	}
    return 0;
}
int CWatermethod::ExtractSubsamplingmethod1(long int blocks,
	                              unsigned short blockwidth,
								  unsigned short blockheight,
								  unsigned short wb,
								  unsigned short hb,
								  unsigned short wmblockheight,
								  unsigned short wmblockwidth,
								  unsigned char *SourceVector1[MAXINPUTVECTORS/4],
								  char *SourceVector2[MAXINPUTVECTORS/4],
								  char *SourceVector3[MAXINPUTVECTORS/4],
								  unsigned char *SourceVector4[MAXINPUTVECTORS/4],
								  unsigned char *pp1[MAXINPUTVECTORS/4],
								  unsigned char *pp2[MAXINPUTVECTORS/4],
                                  int method)
 {
   long int k,l;
   unsigned short int dimension;
   int m;
   unsigned char blktime1[8][8];
   unsigned char *blocktime1[8];
   char blktime2[8][8];
   char *blocktime2[8];
   char blktime3[8][8];
   char *blocktime3[8];
   unsigned char blktime4[8][8];
   unsigned char *blocktime4[8];
   double blkfreq1[8][8];
   double *blockfreq1[8];
   double blkfreq2[8][8];
   double *blockfreq2[8];
   double blkfreq3[8][8];
   double *blockfreq3[8];
   double blkfreq4[8][8];
   double *blockfreq4[8];
   unsigned char wmblktime[4][4];
   unsigned char *wmblocktime[4];
   unsigned char wmblktime1[4][4];
   unsigned char *wmblocktime1[4];
 
   for(l=0;l<MAXBLOCKHEIGHT;l++)
   {
	   blocktime1[l]=blktime1[l];
	   blockfreq1[l]=blkfreq1[l];
	   blocktime2[l]=blktime2[l];
	   blockfreq2[l]=blkfreq2[l];
	   blocktime3[l]=blktime3[l];
	   blockfreq3[l]=blkfreq3[l];
	   blocktime4[l]=blktime4[l];
	   blockfreq4[l]=blkfreq4[l];
   }
   for(l=0;l<wmblockheight;l++)
   {
	   wmblocktime[l]=wmblktime[l];
	   if(pp2!=0)
	   wmblocktime1[l]=wmblktime1[l];
   }
   dimension=blockwidth*blockheight;
   if(blocks>MAXENCODEVECTORS)
   	  return -1;
   	for(m=0;m<32*32;m++)
	{
		//Transmit one block data of the original image to the blocktime block of the original image 
		for(l=0;l<blockheight;l++)
		  for(k=0;k<blockwidth;k++) 	
		  {
		    blktime1[k][l]=SourceVector1[m][k+l*blockwidth];
		 	blktime2[k][l]=SourceVector2[m][k+l*blockwidth];
		 	blktime3[k][l]=SourceVector3[m][k+l*blockwidth];
		 	blktime4[k][l]=SourceVector4[m][k+l*blockwidth];
		  }
		  //DCT is use for one sub block of the original image
		DCT(blocktime1,blockfreq1,blockwidth,blockheight);
		DCT1(blocktime2,blockfreq2,blockwidth,blockheight);
		DCT1(blocktime3,blockfreq3,blockwidth,blockheight);
		DCT(blocktime4,blockfreq4,blockwidth,blockheight);
      if(method==1)
        samplingextract(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,blockwidth,blockheight);
      if(method==2)
        DMBsamplingextract(blockfreq1,blockfreq2,blockfreq3,blockfreq4,wmblocktime,wmblocktime1,blockwidth,blockheight);
		//Transmit one block data of the original watermark image to the blocktime block of the original watermark image
	    for(l=0; l<wmblockheight;l++)
		  for(k=0; k<wmblockwidth;k++)	
		  {
			  pp1[m][k+l*4]=wmblktime[k][l];
			  if(pp2!=0)
			  pp2[m][k+l*4]=wmblktime1[k][l];
		  }
	}
    return 0;
}*/

⌨️ 快捷键说明

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