Xem mẫu

  1. printf("\nPress any key to exit."); getch() ; exit(1); } nsq=filelength(fileno(fptr)); printf("Is this a square image ?"); printf("\n i.e. Is image_length=image width (y or n)? -> "); while(((ch=tolower(getch()))!='y')&&(ch!='n')); putch(ch); switch(ch) { case 'y': image_length=image_width=sqrt(nsq); printf("\n Image size = %d x %d",image_length, image_width); break; case 'n': printf("\nEnter image_width-->"); scanf("%d",&image_width); image_length=nsq/image_width; printf("image length is %d", image_length); break; } printf("\nEnter file name for filtered image ->"); scanf("%s",file_name); ind=access(file_name,0); while(!ind) { gotoxy(1,6); printf("File exists. Wish to overwrite? (y or n)-->"); while(((ch=tolower(getch()))!='y')&&(ch!='n')); putch(ch); switch(ch) { case 'Y': ind=1; break; case 'n': gotoxy(1,6); 70
  2. printf(" "); gotoxy(1,5); printf(" "); gotoxy(1,5); printf("Enter file name -->"); scanf("%s",file_name); ind=access(file_name,0); } } fptr1=fopen(file_name,"wb"); gotoxy(70,25); textattr(WHITE+(GREEN
  3. { y1=y2=(int)0; for(k1=-1; k1
  4. K irsh Compass operator. */ #include #include #include #include #include #include #include /* Kirsh operators. */ int T[8][3][3]={ { {5,5,5}, {-3,0,-3}, {-3,-3,-3},}, {{5,5,-3}, {5,0,-3}, {-3,-3,-3}, }, {{5,-3,-3}, {5,0,-3}, {5,-3,-3},}, {{-3,-3,-3}, {5,0,-3}, {5,5,-3},}, {{-3,-3,-3}, {-3,0,-3}, {5,5,5},}, {{-3,-3,-3}, {-3,0,5}, {-3,5,5},}, {{-3,5,5}, {-3,0,5}, {-3,-3,5},}, {{-3,5,5}, 73
  5. {-3,0,5}, {-3,-3 ,-3},} }; void main() { int i,j,n1,n2,image_width, image_length,k1,k2,ind; char file_name[14],ch; unsigned char **w; unsigned char *temp,tmp; int y[8] ; float nsq; unsigned int zn2; FILE *fptr, *fptr1; clrscr (); printf("Enter file name for input image ->"); scanf("%s",file_name); if((fptr=fopen(file_name,"rb"))==NULL) { p rintf("%s does not exist.", file_name); p rintf("\nPress any key to exit."); getch (); exit(1); } nsq=filelength(fileno(fptr)); printf("Is this a square image ?"); printf ("\n i.e. Is image_length=image_width (y or n)? ->"); while(((ch=tolower(getch()))!='y')&&(ch!='n')); putch(ch); switch(ch) { case 'y': image_length=image_width=sqrt(nsq); printf("\n Image size = %d x %d",image_length, image_width); break; case 'n': printf("\nEnter image_width-->"); scanf("%d",&image_width); 74
  6. image_length=nsq/image_width; printf("image length is %d", image_length); break; } printf("\nEnter file name for filtered image ->"); scanf("%s",file_name); ind=access(file_name,0); while(!ind) { gotoxy(1,6); printf("File exists. Wish to overwrite? (y or n)-->"); while(((ch=tolower(getch()))!='Y')&&(ch!='n')); putch(ch); switch(ch) { case 'y': ind=1; break; case 'n': gotoxy(1,6); printf (" "); gotoxy(1,5); printf(" "); gotoxy(1,5); printf("Enter file name -->"); scanf("%s",file_name); ind=access(file_name,0); } } fptr1=fopen(file_name,"wb"); gotoxy(70,25); textattr(WHITE+(GREEN
  7. for(i=0;i
  8. for(j=0; j
  9. Hình 5.5 (a) Kết quả thu được khi dùng xử lý Sobel trên hình 4.19. (b) K ết quả của xử lý Kirsh trên hình 4.19. 78
  10. CHƯƠNG 6 BIẾN ĐỔI FOURIER RỜI RẠC 6.1 Chỉ dẫn Trong chương 2,chúng ta đã chứng minh rằng đáp ứng tần số của hệ thống của hệ thống tuyến tính bất biến (LSI ) 2-D được cho bởi:    j (1k1  2 k 2 )   h ( k , k )e (6.1) H (1 ,  2 )  1 2 k1   k 2   Nếu h(k1,k2) chỉ có chỉ tồn tại với k1  0, k  0 và tổng quát được xác định 2 trong miền hữu hạn có kích thước N  N thì N 1 N 1   h(k1, k 2 )e  j ( k  k ) (6.2) H (1 ,  2 )  11 22 k1 0k 2 0 Công thức này chứng tỏ rằng H ( 1 ,  2 ) là tuần hoàn, chu kỳ tuần hoàn là 2. Nếu chúng ta lấy mẫu dưới dạng  1, 2, và miền xác định là (0   1  2) và (0  2  2), N  N mẫu, chúng ta có thể viết: 2 2 và  2  (6.3) 1  n1 n2 N N N 1 N 1  j 2  n1k1  n2 k 2  H (n1 , n 2 )    h(k 1 , k 2 )e vì thế (6.4) N k1  0 k 2  0 Biểu thức (6.4) được gọi là biến đổi Fourier rời rạc 2-D hay còn gọi là DFT. Công thức này được áp dụng vào nhiều ứng dụng như lọc, nén ảnh, phóng đại ảnh. Trong chương này chúng ta sẽ nghiên cứu 2-D DFT và các kỹ thuật tính toán. Đầu tiên, chúng ta sẽ xem xét 1-D DFT, sau đó mở rộng ra cho 2-D. 6.2 Biến đổi Fourier 1-D Biến đổi Fourier 1-D cho tín hiệu thời gian rời rạc f(kT) tính theo công thức : N 1  j 2 nk F (n)   f (kT )e (6.5) N k 0 Công thức này có thể viết lại dưới dạng 75
nguon tai.lieu . vn