已閱讀5頁,還剩11頁未讀, 繼續(xù)免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
#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()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/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, 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;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)tempij = 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 * 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 (flag = 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_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 + 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 * 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 - 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 + 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 * orgij - 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 * orgij + 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_HPF1 * 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_LPF4 * 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+)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 = 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_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 (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; 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 tempheightwidth, 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/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; 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 + 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+)for (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 = height/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 height/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 = height/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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國拖掃一體機器人市場深度分析及投資戰(zhàn)略咨詢報告
- 家電行業(yè)投融資居間協(xié)議
- 互聯(lián)網(wǎng)教育項目投資居間
- 湖北藝術職業(yè)學院《機械設計學》2023-2024學年第一學期期末試卷
- 2025年度鮮花店花卉種子及種苗購銷合同范本3篇
- 2025年快遞區(qū)域經(jīng)營權出讓合同3篇
- 眉山四川眉山市東坡區(qū)農(nóng)業(yè)農(nóng)村局選聘特聘農(nóng)技員2人筆試歷年參考題庫附帶答案詳解
- 玉溪云南玉溪江川區(qū)防震減災局招聘城鎮(zhèn)公益性崗位工作人員筆試歷年參考題庫附帶答案詳解
- 滁州安徽滁州天長市水利局機關綜合服務中心選調(diào)工作人員筆試歷年參考題庫附帶答案詳解
- 河北2024年河北勞動關系職業(yè)學院招聘54人筆試歷年參考題庫附帶答案詳解
- 湖南省建設工程施工階段監(jiān)理服務費計費規(guī)則【實用文檔】doc
- GB/T 6913-2008鍋爐用水和冷卻水分析方法磷酸鹽的測定
- GB/T 18717.2-2002用于機械安全的人類工效學設計第2部分:人體局部進入機械的開口尺寸確定原則
- 教案:第三章 公共管理職能(《公共管理學》課程)
- 中國文化概論(第三版)全套課件
- 117-鋼結構工程質(zhì)量常見問題與管控措施
- SHS5230三星指紋鎖中文說明書
- 諾和關懷俱樂部對外介紹
- 保定市縣級地圖PPT可編輯矢量行政區(qū)劃(河北省)
- 新蘇教版科學六年級下冊全冊教案(含反思)
- 供方注冊指南-ZTE
評論
0/150
提交評論