intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Nén Ảnh part 5

Chia sẻ: Asg Ahsva | Ngày: | Loại File: PDF | Số trang:12

68
lượt xem
12
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Tham khảo tài liệu 'nén ảnh part 5', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả

Chủ đề:
Lưu

Nội dung Text: Nén Ảnh part 5

  1. Ch­¬ng tr×nh 13.6 "IFCT2D.C". §¶o ng­îc FCT. KÝch th­íc khèi sö dông trªn ¶nh gèc. /*Program 13.6 "IFCT2D.C". Inverse FCT. Block size used on the original image should be known to the user.*/ /* This program is for carrying out the inverse of the 2-D Fast Cosine Transform. */ #define PI 3.14159 #include #include #include #include #include #include void IFCT(float *, unsigned int *, float *, int , int ); void bit_reversal(unsigned int *, int , int ); void WTSINV(float *,int, int); void main() { int m,N,i,j,k1,k2,NB,NT,NS,k; float *x,*C,**w; unsigned int *L; double nsq; FILE *fptri, *fptro; char file_name[14] ; float *buffi ; unsigned char *buffo; clrscr(); printf ( "This program is for the inverse 2-D FCT . \n" ) ; printf ( "Enter name of input file --->") ; scanf ("%s " , file_name) ; fptri=fopen(file_name, " rb"); if( fptri ==NULL) { printf("\nNo such file exists.\n"); exit(1); } 357
  2. nsq=(double)filelength(fileno(fptri)); /*-------------------- Assume image is square, ----------------------*/ N=(int)sqrt(nsq/sizeof(float)); m=(int)(log10((double)N)/log10((double)2.0)); k=1; for(i=0; im) ; /*------------------------------------ 358
  3. 2-D inverse FCT using the row-column approach. ----------------------------------- */ for(i=0;i
  4. MASK=1; C=0; for(i=0,j=m-1;i>i; A
  5. x[0]*=(float)N/1.414; for(i=1;i=1;k--) for(i=0;i
  6. { for(k=0;k
  7. 3. HiÓn thÞ IKRAMR.IMG. So s¸nh ¶nh nµy víi ¶nh IKRAM.IMG. TiÕp theo t«i sÏ giíi thiÖu mét ch­¬ng tr×nh mµ sÏ hiÓn thÞ c¸c khèi 8  8 cña kÕt qu¶ ®· chuyÓn ®æi trªn mµn h×nh v¨n b¶n. Chó ý r»ng gi¸ trÞ sÏ gi¶m xuèng mét c¸ch nhanh chãng kÓ tõ gãc tr¸i cña mµn h×nh, hay lµ ®iÓm tÇn sè (0,0). §Ó tho¸t khái ch­¬ng tr×nh nµy, bÊm ESC. Ch­¬ng tr×nh 13.7 "DISPFCT.C". Ch­¬ng tr×nh hiÓn thÞ khèi 2-D FCT. /*Program 13.7 "DISPFCT.C". Program to display 2- D FCT blocks.*/ /* This program displays the result of the 2-D FCT. */ #include #include #include #include #include #include void main( ) { int i,j,k1,k2,N,N1,NB,NS; float *buff,nsq; FILE *fptr; char file_name[14]; int ch; clrscr(); printf("Enter input file name containing 2-D FCT result.-->"); scanf("%s",file_name); fptr=fopen(file_name,"rb"); if(fptr==NULL) { printf("\nNo such file exists.\n"); exit(1); } nsq=(float)filelength(fileno(fptr)); 363
  8. N=sqrt((double)(nsq/sizeof(float))); printf("\nEnter block size used (8x8, 16x16, etc.)-->"); scanf("%dx%d",&NB,&NB); N1=N/NB; NS=NB*N; buff=(float *)malloc(NS*sizeof(float)); printf("\nPress ESC to exit."); clrscr(); for(i=0;i
  9. 13.4.2 Sù phãng to vµ sù thu nhá cña c¸c ¶nh Mét trong c¸c øng dông cña FCT lµ thay ®æi kÝch th­íc cña ¶nh, bao gåm sù phãng to vµ sù thu nhá ¶nh. Chóng ta sÏ chÊp nhËn r»ng mét ¶nh phãng to dïng FCT th× sÏ kh«ng cã g× kh¸c so víi mét ¶nh phãng to dïng FFT, trong ®ã ta dïng c¸c thuéc tÝnh vèn cã cña FFT cña ¶nh. Toµn bé ý t­ëng lµ ta sÏ chia tÇn sè lÊy mÉu bªn trong víi 2 vµ nh­ vËy sÏ t¨ng gÊp ®«i kho¶ng c¸ch tÇn sè. Khi FCT cña mét khèi gi¶m rÊt nhanh kÓ tõ ®iÓm tÇn sè (0,0), chóng ta cã thÓ nh©n ®«i kho¶ng c¸ch tÇn sè b»ng c¸ch thªm vµo c¸c ®iÓm 0. §iÒu nµy lµm cho chóng ta gi¶m ®­îc mét nöa tÇn sè lÊy mÉu bªn trong vµ t¨ng gÊp ®«i kÝch th­íc cña ¶nh. V× vËy trong t­¬ng lai, kü thuËt truyÒn h×nh ph¶i sö dông kü thuËt ¶nh sè, th× tÝnh chÊt nµy cã thÓ gióp cho ta t¹o ra ®­îc c¸c tivi cã mµn ¶nh réng. Sù thu nhá thùc hiÖn b»ng c¸ch bít ®i c¸c gi¸ trÞ cña tÇn sè cao. Ch­¬ng tr×nh sau ®©y sÏ phãng to cña mét ¶nh. Ch­¬ng tr×nh nµy yªu cÇu FCT cña mét ¶nh vµ kÝch th­íc cña c¸c khèi trªn ¶nh gèc. KÕt qu¶ ch¹y ch­¬ng tr×nh nµy lµ mét ¶nh cã kÝch th­íc gÊp ®«i. Ch­¬ng tr×nh 13.8 "IFCT2DX.C". Ch­¬ng tr×nh phãng to ¶nh gÊp ®«i dïng 2-D FCT. /*Program 13.8 "IFCT2DX.C". Program for image doubling using the 2-D FCT. The 2-D FCT of the image is the input file.*/ /* This program is for carrying out the inverse of the 2-D Fast Cosine Transform. It doubles the size of the image at the same time. */ #define PI 3.14159 #include #include #include #include #include #include void IFCT(float *, unsigned int *, float *, int , int ); void bit_reversal(unsigned int *, int , int ); void WTSINV(float *,int, int); 365
  10. void main() { int m,N,i,j,k1,k2,NB,NS,N1,NB1,m1,NT,NT1,k; float *x,*C,**w; unsigned int *L; double nsq; FILE *fptri,*fptro; char file_name[14]; float *buffi; unsigned char *buffo; clrscr(); printf ("This program is for the inverse 2-D FCT. \n" ) ; printf("It doubles the size of the image at the same time."); printf("\nEnter name of input file --- > " ) ; scanf("%s",file_name); fptri=fopen(file_name,"rb"); if(fptri==NULL) { printf("\nNo such file exists.\n"); exit(1); } nsq=(double)filelength(fileno(fptri)); /*--------------------- Assume image is square. -----------------------*/ N=(int)sqrt(nsq/sizeof(float)); m=(int)(log10((double)N)/log10((double)2.0)); k=1; for(i=0;i
  11. fptro=fopen(file_name,"wb"); printf("\nEnter block size used (e.g. 8x8,16xl6) --- >"); scanf ( "%dx%d" , &NB , &NB ) ; m=(int)(log10((double)NB)/log10((double)2.0)); NT=N*NB; /*----------------------------- Blocks of NBxNB were considered by the FCT. Output blocks are (2xNB)x(2xNB). -------------------------------*/ m1=m+1; NB1=NB
  12. { for(k2=0;k2
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2