470 likes | 555 Views
TB-058. 儒林圖書公司 印行. 第五章:頻率領域影像處理. 5.1 簡介 5.2 快速傅立葉轉換 5.3 影像傅立葉轉換 5.4 頻域濾波器 5.5 程式發展 5.6 實作練習 5.7 程式分析 5.8 測驗題. 5.1. 簡介. 5.2. 快速傅立葉轉換. ······(5.7). ······(5.8). ··············(5.9). ··········································(5.10).
E N D
TB-058 儒林圖書公司 印行 第五章:頻率領域影像處理
第五章:頻率領域影像處理 • 5.1 簡介 • 5.2 快速傅立葉轉換 • 5.3 影像傅立葉轉換 • 5.4 頻域濾波器 • 5.5 程式發展 • 5.6 實作練習 • 5.7 程式分析 • 5.8 測驗題 第五章:頻率領域影像處理
5.1 簡介 第五章:頻率領域影像處理
5.2 快速傅立葉轉換 ······(5.7) ······(5.8) 第五章:頻率領域影像處理
··············(5.9) ··········································(5.10) ·········································(5.11) ·····················(5.12) 第五章:頻率領域影像處理
【運算個數】 ······························(5.13) 第五章:頻率領域影像處理
【簡化】 ·····································(5.14) ·····································(5.15) 第五章:頻率領域影像處理
·········································(5.16)·········································(5.16) ·········································(5.17) ·········································(5.18) 第五章:頻率領域影像處理
5.3 影像傅立葉轉換 ·········(5.19) ··································(5.20) 第五章:頻率領域影像處理
二維傅立葉轉換的性質 (1) 週期性 (2) 對稱性 (3) 直流成份 (4) 頻譜顯示 (5) 變數分離 第五章:頻率領域影像處理
··········(5.21) ···(5.22) ··················(5.23) ·················································(5.24) 第五章:頻率領域影像處理
································(5.25)································(5.25) ·················································(5.26) ···(5.27) ·········(5.28) 第五章:頻率領域影像處理
5.4 頻域濾波器 ·····················(5.29) 第五章:頻率領域影像處理
·······························(5.30)·······························(5.30) ·······························(5.31) 第五章:頻率領域影像處理
··························(5.32) 第五章:頻率領域影像處理
·······················(5.33) ·············(5.34) ············(5.35) 第五章:頻率領域影像處理
··············(5.36) ·································(5.37) 第五章:頻率領域影像處理
·······················(5.38) 第五章:頻率領域影像處理
圖5-23 頻域影像處理範例 第五章:頻率領域影像處理
圖5-23 頻域影像處理範例 (續) 第五章:頻率領域影像處理
5.5 程式發展 這一章包含 4 個副程式,分別說明如下: Void Char2 Complex (COMPLEX*F,n) 將以 (OFFSETX,OFFSETY) 為起始點的 n*n 影像轉換為複數矩陣,COMPEX 為自訂複數結構。 Void-1DFFT (COMPLEX*F,int log2n,int n,int ntype) 執行一維正反快速傅立葉轉換。 Void-2DFFT (COMPLEX*F,int n,int log2n,int ntype) 執行 n*n 二維正反傅立葉轉換。 第五章:頻率領域影像處理
【範例1】: test5-1.c #include "image.lib"main(){ struct COMPLEX F[64*64]; int i,j, n=64, log2n=6; char str[40]; printf("\n ** PLS. INPUT THE NAME OF IMAGE FILE :"); gets(str); Setvga256(); Inipalette(); Loadimage(str); Sinwave_Noise(16,16,0); getch(); Char2Complex(F,n); _2Dfft(F,n,log2n,0); /* forward FFT */ Spectrum(F,n,0); getch(); _2Dfft(F,n,log2n,1); /* Inverse FFT */ Spectrum(F,n,1); getch(); Settext();} 第五章:頻率領域影像處理
5.7 程式分析 void Char2Complex (struct COMPLEX *f, int n){ int i,j; for (j=0; j<n; j++) for (i=0; i<n; i++) { f[j*n+i].r=Getpixel (OFFSETX+i, OFFSETY+j); f[j*n+i].i=0; }}void Spectrum(struct COMPLEX *f, int n, int type){ int i,j; float frequency, avg=0.; for (j=0; j<n; j++) for (i=0; i<n; i++) { if (type == 0) { frequency = logl0(1 + sqrt( (f[j*n+i].r * f[j*n+i].r) +(f[j*n+i].i * f[j*n+i].i))); if ((j == 0) && (i == 0)) avg=255./frequency; Putpixel(OFFSETX+(i+(n/2))%n,OFFSETY+(j+(n/2))%n, (char)avg*fr equency); } else Putpixel(OFFSETX+i, OFFSETY+j, (char) f[j*n+i].r); }} (1) 圖5-25 二維傅立葉轉換副程式 第五章:頻率領域影像處理
void _2Dfft (struct COHPLEX *F, int n, int log2n, int ntype){ int i, j; struct COMPLEX temp[64]; /* the maximum size is 64*64 */ for (i=0; i<n; i++) _1Dfft(F+n*i, log2n, n, ntype); for (i=0; i<n; i++) { for (j=0; j<n; j++) temp[j]=F[j*n+i]; _1Dfft (temp, log2n, n, ntype); for (j=0; j<n; j++) F[j*n+i] = temp[j]; }} (2) (3) 圖5-25 二維傅立葉轉換副程式(續) 第五章:頻率領域影像處理