版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《家庭護(hù)士》課件
- 2023-2024學(xué)年福建省福州市福清市高一(下)期中地理試卷
- 高速公路施工總承包合同段春節(jié)節(jié)后復(fù)工工作計(jì)劃及保障措施
- 2024年山東省日照市公開招聘警務(wù)輔助人員輔警筆試自考題2卷含答案
- 2024年福建省福州市公開招聘警務(wù)輔助人員輔警筆試自考題2卷含答案
- 2024年四川省眉山市公開招聘警務(wù)輔助人員輔警筆試自考題2卷含答案
- 2021年貴州省安順市公開招聘警務(wù)輔助人員輔警筆試自考題1卷含答案
- 湖南省張家界市(2024年-2025年小學(xué)六年級(jí)語文)部編版摸底考試(上學(xué)期)試卷及答案
- 2024年ATM機(jī)項(xiàng)目資金需求報(bào)告代可行性研究報(bào)告
- 2025年P(guān)S鋁合金板項(xiàng)目立項(xiàng)申請(qǐng)報(bào)告模板
- 職業(yè)技術(shù)學(xué)院《茶藝》課程標(biāo)準(zhǔn)
- 2024-2025學(xué)年北京市海淀區(qū)數(shù)學(xué)三上期末教學(xué)質(zhì)量檢測(cè)試題含解析
- 敏捷開發(fā)與Scrum考核試卷
- 2025屆江蘇省連云港市東??h數(shù)學(xué)八上期末學(xué)業(yè)質(zhì)量監(jiān)測(cè)試題含解析
- 四年級(jí)豎式100道
- 2024年工業(yè)廢水處理工(初級(jí))技能鑒定考試題庫(kù)(含答案)
- 2024新滬教版英語初一上單詞表(英譯漢)
- 人教版八年級(jí)上冊(cè)生物期末必刷15道識(shí)圖題
- 期末專題復(fù)習(xí)-任務(wù)型閱讀 2023-2024學(xué)年 外研版英語八年級(jí)上學(xué)期期末真題備考
- 配電室設(shè)備安裝工程施工方案
- 組織學(xué)與胚胎學(xué)智慧樹知到期末考試答案章節(jié)答案2024年中南大學(xué)
評(píng)論
0/150
提交評(píng)論