版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、#include #include#define height 256#define width 256void twoDDWT(double orgwidth, double dwtwidth,int NumofBand);void oneDDWT(int flag, double orgwidth, double dwtwidth);void twoDIDWT(double dwtwidth, double recwidth,int NumofBand);void oneDIDWT(int flag, double dwtwidth, double recwidth);int main()
2、int i, j;double orgheightwidth, dwtheightwidth,recheightwidth;FILE *lena;FILE *lena3; FILE *lena4;lena = fopen(c:lena.raw, rb);lena3 = fopen(c:lena3.raw, wb);lena4 = fopen(c:lena4.raw, wb);for (i = 0; i height; i+) for (j = 0; j width; j+)orgij = fgetc(lena);twoDDWT(org, dwt,4);for (i = 0; i height/
3、2; i+)for (j = 0; j width/2; j+)orgij=dwtij;twoDDWT(org, dwt,7);for (i = 0; i height; i+)for (j = 0; j width; j+)fputc(dwtij, lena3);twoDIDWT(dwt, rec,7);for (i = 0; i height/2; i+)for (j = 0; j width/2; j+)dwtij=recij;twoDIDWT(dwt, rec,4);for (i = 0; i height; i+)for (j = 0; j width; j+)fputc(recij
4、, lena4);return 0;void twoDDWT(double orgwidth, double dwtwidth,int NumofBand)if (NumofBand=4)oneDDWT(0, org, dwt);oneDDWT(1, org, dwt);if (NumofBand=7)oneDDWT(2, org, dwt);oneDDWT(3, org, dwt); void oneDDWT(int flag, double orgwidth, double dwtwidth)int i, j;double tempheightwidth, temp1heightwidth
5、;double f_LPF = -0.125, 0.25, 0.75, 0.25, -0.125 ;double f_HPF = -0.5, 1, -0.5 ;if (flag = 0)/vertical direction for (i = 0; i height; i+) for (j = 0; j 1 & j height-2)tempij = f_LPF0 * orgij - 2 + f_LPF1 * orgij - 1 + f_LPF2 * orgij + f_LPF3 * orgij + 1 + f_LPF4 * orgij + 2;else if (j = height-2)te
6、mpij = f_LPF0 * orgij - 2 + f_LPF1 * orgij - 1 + f_LPF2 * orgij + f_LPF3 * orgij + 1 + f_LPF4 * orgij;else if (j = height-1)tempij = f_LPF0 * orgij - 2 + f_LPF1 * orgij - 1 + f_LPF2 * orgij + f_LPF3 * orgij - 1 + f_LPF4 * orgij - 2;for (i = 0; i height; i+)for (j = 0; j width/2; j+)dwtij = tempij *
7、2 + 1;for (i = 0; i height; i+)for (j = 0; j 0 & j height-1)tempij = f_HPF0 * orgij - 1 + f_HPF1 * orgij + f_HPF2 * orgij + 1;else if (j = height-1)tempij = f_HPF0 * orgij - 1 + f_HPF1 * orgij + f_HPF2 * orgij - 1;for (i = 0; i height; i+)for (j = 0; j width/2; j+)dwtij + width/2 = tempij * 2;if (fl
8、ag = 1)/horizontal directionfor (i = 0; i height; i+)for (j = 0; j 1 & i width-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LPF4 * dwti + 2j;else if (i = width-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f
9、_LPF4 * dwtij;else if (i = width-1)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti - 1j + f_LPF4 * dwti - 2j;for (i = 0; i height; i+)for (j = 0; j width; j+)temp1ij = tempi * 2 + 1j;for (i = 0; i height; i+)for (j = 0; j 0 & i width-1)tempij = f_HPF0 * dwti - 1j +
10、f_HPF1 * dwtij + f_HPF2 * dwti + 1j;else if (i = width-1)tempij = f_HPF0 *dwti - 1j + f_HPF1 * dwtij + f_HPF2 * dwti - 1j;for (i = 0; i height; i+) for (j = 0; j width/2; j+)temp1ij+width/2 = tempi * 2j;for (i = 0; i height; i+)for (j = width/2; j 1 & i height-2)tempij = f_LPF0 * dwti - 2j + f_LPF1
11、* dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LPF4 * dwti + 2j;else if (i = height-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LPF4 * dwtij;else if (i = height-1)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti
12、 - 1j + f_LPF4 * dwti - 2j;for (i = 0; i height; i+)for (j = width/2; j width; j+)temp1i+height/2j-width/2 = tempi * 2 + 1j;for (i = 0; i height; i+)for (j = width/2; j 0 & i height-1)tempij = f_HPF0 * dwti - 1j + f_HPF1 * dwtij + f_HPF2 * dwti + 1j;else if (i = height-1)tempij = f_HPF0 * dwti - 1j
13、+ f_HPF1 * dwtij + f_HPF2 * dwti - 1j;for (i = 0; i height; i+)for (j = width/2; j width; j+)temp1i +height/2j = tempi * 2j;for (i = 0; i height; i+)for (j = 0; j width; j+)dwtij = temp1ij;if (flag = 2)/vertical directionfor (i = 0; i height/2; i+)for (j = 0; j 1 & j height/2-2)tempij = f_LPF0 * org
14、ij - 2 + f_LPF1 * orgij - 1 + f_LPF2 * orgij + f_LPF3 * orgij + 1 + f_LPF4 * orgij + 2;else if (j = height/2-2)tempij = f_LPF0 * orgij - 2 + f_LPF1 * orgij - 1 + f_LPF2 * orgij + f_LPF3 * orgij + 1 + f_LPF4 * orgij;else if (j = height/2-1)tempij = f_LPF0 * orgij - 2 + f_LPF1 * orgij - 1 + f_LPF2 * o
15、rgij + f_LPF3 * orgij - 1 + f_LPF4 * orgij - 2;for (i = 0; i height/2; i+)for (j = 0; j width/4; j+)dwtij = tempij * 2 + 1;for (i = 0; i height/2; i+)for (j = 0; j 0 & j height-1)tempij = f_HPF0 * orgij - 1 + f_HPF1 * orgij + f_HPF2 * orgij + 1;else if (j = height-1)tempij = f_HPF0 * orgij - 1 + f_H
16、PF1 * orgij + f_HPF2 * orgij - 1;for (i = 0; i height/2; i+)for (j = 0; j width/4; j+)dwtij + width/4 = tempij * 2;if (flag = 3)/horizontal directionfor (i = 0; i height/2; i+)for (j = 0; j 1 & i height/2-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LP
17、F4 * dwti + 2j;else if (i = height/2-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LPF4 * dwtij;else if (i = height/2-1)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti - 1j + f_LPF4 * dwti - 2j;for (i = 0; i height/4; i
18、+)for (j = 0; j width/4; j+)temp1ij = tempi * 2 + 1j;for (i = 0; i height/2; i+)for (j = 0; j 0 & i height/2-1)tempij = f_HPF0 * dwti - 1j + f_HPF1 * dwtij + f_HPF2 * dwti + 1j;else if (i = height/2-1)tempij = f_HPF0 * dwti - 1j + f_HPF1 * dwtij + f_HPF2 * dwti - 1j;for (i = 0; i height/4; i+)for (j
19、 = 0; j width/4; j+)temp1i + height/4j = tempi * 2j;for (i = 0; i height/2; i+)for (j = width/4; j 1 & i height/2-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LPF4 * dwti + 2j;else if (i = height/2-2)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f
20、_LPF2 * dwtij + f_LPF3 * dwti + 1j + f_LPF4 * dwtij;else if (i = height/2-1)tempij = f_LPF0 * dwti - 2j + f_LPF1 * dwti - 1j + f_LPF2 * dwtij + f_LPF3 * dwti - 1j + f_LPF4 * dwti - 2j;for (i = 0; i height/4; i+)for (j = width/4; j width/2; j+)temp1ij = tempi * 2 + 1j;for (i = 0; i height/2; i+)for (
21、j = width/4; j 0 & i width/2-1)tempij = f_HPF0 * dwti - 1j + f_HPF1 * dwtij + f_HPF2 * dwti + 1j;else if (i = width/2)tempij = f_HPF0 * dwti - 1j + f_HPF1 * dwtij + f_HPF2 * dwti - 1j;for (i = 0; i height/4; i+)for (j = width/4; j width/2; j+)temp1i + height/4j = tempi * 2j; for (i = 0; i height/2;
22、i+)for (j = 0; j width/2; j+)dwtij = temp1ij;void twoDIDWT(double dwtwidth, double recwidth,int NumofBand)if (NumofBand=7)oneDIDWT(2, dwt, rec);oneDIDWT(3, dwt, rec);if (NumofBand=4)oneDIDWT(1, dwt, rec);oneDIDWT(0, dwt, rec);void oneDIDWT(int flag, double dwtwidth, double recwidth)int i, j;double t
23、empheightwidth, temp1heightwidth;double i_LPF = 0.5, 1, 0.5 ;double i_HPF = -0.125, -0.25, 0.75, -0.25, -0.125 ;if (flag = 2)/horizontal directionfor (i = 0; i height/2; i+)for (j = 0; j width/4; j+)if (i % 2 = 1)tempij = dwti / 2j;elsetempij = 0;for (i = 0; i height/2; i+)for (j = 0; j 0 & i height
24、/2-1)recij = i_LPF0 * tempi - 1j + i_LPF1 * tempij + i_LPF2 * tempi + 1j;else if (i = height/2-1)recij = i_LPF0 * tempi - 1j + i_LPF1 * tempij + i_LPF2 * tempi - 1j;for (i = height/4; i height/2; i+)for (j = 0; j width/4; j+)dwti - height/4j = dwtij;for (i = 0; i height/2; i+)for (j = 0; j width/4;
25、j+)if (i % 2 = 0)tempij = dwti / 2j;elsetempij = 0;for (i = 0; i height/2; i+)for (j = 0; j 1 & i height/2-2)temp1ij = i_HPF0 * tempi - 2j + i_HPF1 * tempi - 1j + i_HPF2 * tempij + i_HPF3 * tempi + 1j + i_HPF4 * tempi + 2j;else if (i = height/2-2)temp1ij = i_HPF0 * tempi - 2j + i_HPF1 * tempi - 1j +
26、 i_HPF2 * tempij + i_HPF3 * tempi + 1j + i_HPF4 * tempij;else if (i = height/2-1)temp1ij = i_HPF0 * tempi - 2j + i_HPF1 * tempi - 1j + i_HPF2 * tempij + i_HPF3 * tempi - 1j + i_HPF4 * tempi - 2j;for (i = 0; i height/2; i+)for (j = 0; j width/4; j+)recij = recij + temp1ij;for (i = 0; i height/4; i+)f
27、or (j = width/4; j width/2; j+)dwtij - height/4 = dwtij;for (i = 0; i height/2; i+)for (j = 0; j width/4; j+)if (i % 2 = 1)tempij = dwti / 2j;elsetempij = 0;for (i = 0; i height/2; i+)for (j = 0; j 0 & i height/2-1)temp1ij = i_LPF0 * tempi - 1j + i_LPF1 * tempij + i_LPF2 * tempi + 1j;else if (i = he
28、ight/2-1)temp1ij = i_LPF0 * tempi - 1j + i_LPF1 * tempij + i_LPF2 * tempi - 1j;for (i = height/4; i height/2; i+)for (j = width/4; j width/2; j+)dwti - height/4j - width/4 = dwtij;for (i = 0; i height/2; i+)for (j = 0; j width/4; j+)if (i % 2 = 0)tempij = dwti / 2j;elsetempij = 0;for (i = 0; i heigh
29、t/2; i+)for (j = 0; j 1 & i height/2-2)dwtij = i_HPF0 * tempi - 2j + i_HPF1 * tempi - 1j + i_HPF2 * tempij + i_HPF3 * tempi + 1j + i_HPF4 * tempi + 2j;else if (i = height/2-2)dwtij = i_HPF0 * tempi - 2j + i_HPF1 * tempi - 1j + i_HPF2 * tempij + i_HPF3 * tempi + 1j + i_HPF4 * tempij;else if (i = heig
30、ht/2-1)dwtij = i_HPF0 * tempi - 2j + i_HPF1 * tempi - 1j + i_HPF2 * tempij + i_HPF3 * tempi - 1j + i_HPF4 * tempi - 2j;for (i = 0; i height/2; i+)for (j = 0; j width/4; j+)recij + width/4 = temp1ij + dwtij;if (flag = 3)/vertical directionfor (i = 0; i height/2; i+)for (j = 0; j width/2; j+)if (j % 2 = 1)tempij = recij / 2;elsetempij = 0;for (i = 0; i height/2; i+)for (j = 0; j 0 & j height/2-1)temp1ij = i_LPF0 * tempij - 1 + i_LPF1 * tempij + i_LPF2 * tempij + 1;else if (j = height/2-1)temp1ij = i_LPF0 * tempij - 1 + i_LPF1 * tempij + i_LPF
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 細(xì)胞呼吸課件教學(xué)課件
- 三年級(jí)數(shù)學(xué)計(jì)算題專項(xiàng)練習(xí)匯編及答案集錦
- 老年活動(dòng)項(xiàng)目標(biāo)前協(xié)議書(2篇)
- 南京航空航天大學(xué)《電磁場(chǎng)的數(shù)值方法》2022-2023學(xué)年期末試卷
- 南京工業(yè)大學(xué)浦江學(xué)院《線性代數(shù)(理工)》2021-2022學(xué)年第一學(xué)期期末試卷
- 分式方程說(shuō)課稿
- 蹲踞式起跑說(shuō)課稿
- angengingong說(shuō)課稿部編版
- 南京工業(yè)大學(xué)浦江學(xué)院《計(jì)算機(jī)網(wǎng)絡(luò)》2023-2024學(xué)年期末試卷
- 黑板字課件教學(xué)課件
- 學(xué)校校園文化建設(shè)協(xié)議書
- 工程機(jī)械租賃服務(wù)方案及保障措施
- GB/T 13077-2024鋁合金無(wú)縫氣瓶定期檢驗(yàn)與評(píng)定
- 有限空間作業(yè)安全承諾書
- 幼兒園預(yù)防近視教師培訓(xùn)
- SY-T 6966-2023 輸油氣管道工程安全儀表系統(tǒng)設(shè)計(jì)規(guī)范
- 人工智能訓(xùn)練師(中級(jí)數(shù)據(jù)標(biāo)注員)理論考試題庫(kù)大全(含答案)
- 醫(yī)院科室合作共建方案
- 3.1DNA是主要的遺傳物質(zhì)課件-高一下學(xué)期生物人教版必修二
- 小學(xué)數(shù)學(xué)計(jì)算專項(xiàng)訓(xùn)練之乘法分配律(提公因數(shù))
- 《食物在體內(nèi)的旅行》說(shuō)課稿
評(píng)論
0/150
提交評(píng)論