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

📄 integerdwt_testedok.c

📁 Implementation of Integerwavelet transform Plus SPIHT encoding for an image
💻 C
📖 第 1 页 / 共 3 页
字号:
											bitCount = bitCount + 1;																												LIP1[LIPcount]=LIP_1;											LIP2[LIPcount]=LIP_2;											LIPcount=LIPcount+1;											LIPsize=LIPsize+1;																		}													                                                              							}										LIS1[currset]=120;						LIS2[currset]=120;						LIS3[currset]=120;						LIS4[currset]=120;						//LISsize = LISsize-1;													}				}						currset = currset + 1;						if (currset > (LIScount - 1))						{							notDone = 0;						}}	 		 tmpLIScount =0;    //% only investigate to the last used index   	for (k1=0;k1<=LISsize;k1++)	{		BB=LIS1[k1];	    CC=LIS2[k1];		if ((BB!= 120))		{            tmpLIS1[tmpLIScount] = LIS1[k1];			tmpLIS2[tmpLIScount] = LIS2[k1];			tmpLIS3[tmpLIScount] = LIS3[k1];			tmpLIS4[tmpLIScount] = LIS4[k1];            
			tmpLIScount = tmpLIScount + 1;        }	}                        //clear tmpLIP;       LIScount = tmpLIScount;    LISsize = tmpLIScount-1;		for (k2=0;k2<=LISsize;k2++)		{		 LIS1[k2]=tmpLIS1[k2]; 		 LIS2[k2]=tmpLIS2[k2];		 LIS3[k2]=tmpLIS3[k2]; 		 LIS4[k2]=tmpLIS4[k2];		}		//////////////////////////////////////////////////////							/////////////////////////////// refinement pass	for (k=0;k<=OldLSPCount;k++)	{		LSP1_1=LSP1[k];		LSP1_2=LSP2[k];		Coeff=Ad[LSP1_1][LSP1_2];        		if (Coeff >0)		{		Ad[LSP1_1][LSP1_2]=Ad[LSP1_1][LSP1_2]+(st[bitCount]*T);		}		else		{		Ad[LSP1_1][LSP1_2]=Ad[LSP1_1][LSP1_2]-(st[bitCount]*T);		}		bitCount = bitCount + 1;    	//for(i=0;i<=bitCount;i++)				}	OldLSPCount = LSPcount - 1;////////////////////////LIS		if (T == 1)		{         break;		}		T = T/2;	}//end of while loop}//END OF FUNCTION/////////////////////////////////////////////////////////////////////void integerdwt(){//begin of integer dwtint i,j,k,a,temp,temp1,temp2,temp3;int columns1;int rows1,rows,columns;
int aa,cc;rows=columns=ROW;//rows=columns=16;
rows1=rows/2;columns1=columns/2;//rows1=rows>>1;
//colomns1=colomns>>1;	//////// one dimensional Even component////////			for (j=0;j<rows;j++)			{				a=1; 			   for (k=0;k<columns1;k++)			   {					Even[j][k]=im[j][a];					a=a+2;			   }			}	//////// one dimensional Odd component////////			for (j=0;j<rows;j++)			{				a=0;			   for (k=0;k<columns1;k++)			   {					Odd[j][k]=im[j][a];					a=a+2;			   }			}///////////For Memory Requirements Purposes Iam just reducing the number of Variables Used////////////
/***************************************************************************************************/
//// High and Low are Replaced By Even and Odd Respectively//////////////////////////////
		////////////  comput L  AND  H pass component			for (j=0;j<rows;j++)			{			   for (k=0;k<columns1;k++)			   {				   				 				//In "temp" Iam taking the "High" and in "Temp1" Iam taking "Low"
				//and we have to repalce High By Even (High -----> Even1)
				// and we have to repalce Low By Odd  (Low -----> Odd1  )
				 
				//High[j][k]=Odd[j][k]-Even[j][k];
				temp = Odd[j][k]-Even[j][k];
				 aa=Odd[j][k]-Even[j][k];				 aa=aa/2;				 cc=ceil(aa);				 //Low[j][k]=(Even[j][k]+cc);			      temp1= (Even[j][k]+cc);
			      
			      Even[j][k]=temp;
			      Odd[j][k]=temp1;
			      
			      
				 }			}/********************************************************************************************/
//// /////////////Low -------> odd   and  High------------>Even//////////////////////////////	///////////////////one dimensional L even     			for (j=0;j<columns1;j++)			{				a=1;			   for (k=0;k<columns1;k++)			   {					LEven[k][j]=Odd[a][j];      ///Odd is Low					HEven[k][j]=Even[a][j];     ///Even is High					a=a+2;			   }			}////////////////////////////////////////////////////////////////		//////// one dimensional  L Odd component////////			for (j=0;j<columns1;j++)			{				a=0;			   for (k=0;k<columns1;k++)			   {						LOdd[k][j]=Odd[a][j];     ///Odd is LOW					HOdd[k][j]=Even[a][j];    ///Even Is HIGH					a=a+2;			   }			}/*****************************************************************************************
For the memory requirements LL LH  Should be replaced With LOdd and LEven  and
                            HL HH  Should be replaced With HOdd and HEven   
n between for transferring properly temp,temp1,temp2,temp3 variables are used
             LL----->LOdd 	(temp)
             LH----->LEven	(temp1)
             HL----->HOdd  	(temp2)
             HH----->HEven  (temp3)
             
******************************************************************************************/                            
			/////////////////////////////////////////////////////////			for (j=0;j<columns1;j++)			{			   for (k=0;k<columns1;k++)			   {				// LH[j][k]=LOdd[j][k]-LEven[j][k];				temp1=LOdd[j][k]-LEven[j][k];  ///temp1===LH
				aa=LOdd[j][k]-LEven[j][k];				 aa=aa/2; 				 cc=ceil(aa);				// LL[j][k]=(LEven[j][k]+cc);				 temp=(LEven[j][k]+cc);        ///temp==LL
				 
				 LOdd[j][k]=temp;              ///LL===LOdd
				 LEven[j][k]=temp1;            ///LH===LEven 
				 
				 
				 
				 //HH[j][k]=HOdd[j][k]-HEven[j][k];				 temp2 = HOdd[j][k]-HEven[j][k];  //temp2===HH
				 aa = HOdd[j][k]-HEven[j][k];				 aa = aa/2;				 cc = ceil(aa);				 //HL[j][k]=(HEven[j][k]+cc);			     temp3 = (HEven[j][k]+cc);         //temp3===HL
			     
			     HEven[j][k] = temp2;              // HEven===HH
			     HOdd[j][k]  = temp3;              // HOdd====HL
			     
				 }			}}// end of integer dwtvoid reversedwt(){//begin of reverse dwtint i,j,k,a,temp,temp1,temp2,temp3;int columns1=COL;//nt columns1=8;
int Lenr =COL;//int Lenr =8;
int Lenc =COL;//int Lenc =8;
int rlen2r=ROW;//int rlen2r=16;
int valc;int aa,cc;/////init the RL RH arrays (4x2)/*****************************************************************************************
For the memory requirements LL LH  Should be replaced With LOdd and LEven  and
                            HL HH  Should be replaced With HOdd and HEven   
n between for transferring properly temp,temp1,temp2,temp3 variables are used
             LL----->LOdd 	(temp)
             LH----->LEven	(temp1)
             HL----->HOdd  	(temp2)
             HH----->HEven  (temp3)
             
******************************************************************************************/

/*****************************************************************************************
For the memory requirements LL LH  Should be replaced With LOdd and LEven  and
                            HL HH  Should be replaced With HOdd and HEven   
n between for transferring properly temp,temp1,temp2,temp3 variables are used
           /*RLL----->LOdd 	(temp)
             RLH----->LEven	(temp1)
             RHL----->HOdd  (temp2)
             RHH----->HEven (temp3)
             
******************************************************************************************/



/*for(i=0;i<ROW;i++){	for(j=0;j<COL;j++){	RL[i][j]=0;	RH[i][j]=0;	}}*/	for (j=0;j<columns1;j++)			{			   for (k=0;k<columns1;k++)			   {				 aa=LEven[j][k];   /////LEven  ---->LH				 aa=aa/2;				 cc=ceil(aa);				 //RLL[j][k]=(LOdd[j][k]-cc);                 
				 temp = (LOdd[j][k]-cc); ////LOdd--->LL				 //RLH[j][k]=RLL[j][k]+LEven[j][k];                 temp1=temp+LEven[j][k];					 aa=HEven[j][k];				 aa=aa/2;				 cc=ceil(aa);				 //RHL[j][k]=(HOdd[j][k]-cc);                 temp2=(HOdd[j][k]-cc);				 
                 //RHH[j][k]=HEven[j][k]+RHL[j][k];                 temp3=HEven[j][k]+temp2;
                 
                 LEven[j][k] =  temp;    //
                 LOdd[j][k] =   temp1;
                 HEven[j][k] =  temp2;
                 HOdd[j][k] =   temp3;
                 
                 }			}		/******************************************************************************
For the Memory Requirements RL---->Even and    ///Odd is LOW
                            RH---->Odd         ///Even is High*******************************************************************************/

					k=0;					for(i=0;i<ROW;i=i+2){						for(j=0;j<COL;j++){							 Odd[i][j]  = LOdd[k][j];  							Even[i][j]  = HOdd[k][j];													}						k++;					}						k=0;					for(i=1;i<ROW;i=i+2){						for(j=0;j<COL;j++){							 Odd[i][j] = LEven[k][j];							Even[i][j] = HEven[k][j];													}						k++;					}/*************************************************************************************
For the Memory requirements R---->Even     ///Odd is LOW
                            H----->Odd     ///Even is High
**************************************************************************************/				for(i=0;i<ROW;i=i+1)						{						for(j=0;j<COL;j++)						{							aa=Even[i][j]/2;							cc=ceil(aa);							//R[i][j]=Even[i][j]-cc;          							temp=Odd[i][j]-cc;
							 
							Odd[i][j] = Even[i][j]+temp;							Even[i][j]= temp;						}											}									for(i=0;i<ROW;i++){							k=0;						for(j=1;j<ROW;j=j+2){							Output[i][j]=Even[i][k];							k++;													}											}									for(i=0;i<ROW;i++){							k=0;						for(j=0;j<ROW;j=j+2){							Output[i][j]=Odd[i][k];							k++;													}											}}// end of reverse dwtvoid  main(){char word[15];char c;int v,m,t;char ch;int manti,tempI,remind;char charVa;int i,j,ind;int index2=0;int temp1,temp2,temp3;int min,index,k; int val,period,Tact;float temp=0;




	period = UART_detectAutobaud();	
	//period = 0xaf73;
	// Apply formula divisor = period / (16 x 8 bits)
 	period = period >> 7;
    //divisor = 0xc0f;
	// UART_init writes the divisor to (DLH:DLL)
	UART_init(period);
	//Enable the UART Clocks
	*pUART_GCTL=0x0001;
	//Disable all the interrupts because we are 
	//using polling approach
	*pUART_IER=0x0000;
    
for(t = 0;t<10 ; t++)
{	 
	while(1)  if(UART_getc()=='@') break;
   
 // 	UART_putc('#');
   	
   	
  	for(i=0;i<64;i++)
  		for(j=0;j<64;j++)
  			im[i][j] = UART_getc();
   			
   		
   
   /************************************************************************************/
   /*********Send the First image through serial port***********************************/

	
					
           /*LL----->LOdd 	(temp)
             LH----->LEven	(temp1)
             HL----->HOdd  	(temp2)
             HH----->HEven  (temp3)*/
						 										integerdwt();				//	printf("matrix all: \n");							for(i=0;i<rowL;i++){							for(j=0;j<colL;j++){								if(i<rowS){									if(j<colS){										Ad[i][j]=LOdd[i][j];									}									else{										Ad[i][j]=LEven[i][j-colS];									}								}								else{									if(j<colS){										Ad[i][j]=HOdd[i-rowS][j];									}									else{										Ad[i][j]=HEven[i-rowS][j-colS];									}													}							//	printf(" %d\n",waveencodeImage[i][j]);							}							//printf("\n");						}					Tact = cSPIHT();

for(i=0;i<64;i++)
	for(j=0;j<64;j++)
	Ad[i][j] = 0;
	
dSPIHT(Tact);

           /*RLL----->LOdd 	(temp)
             RLH----->LEven	(temp1)
             RHL----->HOdd  (temp2)
             RHH----->HEven (temp3)*/
             

/*							for(i=0;i<rowL;i++){							for(j=0;j<colL;j++){													if(i<rowS){									if(j<colS){										LOdd[i][j] = Ad[i][j];									}									else{										LEven[i][j-colS] = Ad[i][j];									}								}								else{									if(j<colS){										HOdd[i-rowS][j] = Ad[i][j];									}									else{										HEven[i-rowS][j-colS] = Ad[i][j];									}													}								//printf(" %d  ",all[i][j]);							}							//printf("\n");						}					*/					reversedwt();


	
   while(1)  if(UART_getc()=='@') break;
   
   UART_putc('#');
   
   /************************************************************************************/
   /*********Send the First image through serial port***********************************/
	for(i=0;i<64;i++)
    for(j=0;j<64;j++) UART_putc(Output[i][j]);
}

/***For Loop End******/}

⌨️ 快捷键说明

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