版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
現(xiàn)鄰域平均法是簡單的空域圖像平滑化處理方法,對圖像噪聲的去除有一定的效#ifndefBMP_H_4_INCLUDED#defineBMP_H_4_INCLUDEDtypedefunsignedshortWORD;typedefunsignedlongDWORD;typedeflongLONG;typedefunsignedcharBYTE;typedefstructtagBITMAPFILEHEADER{//bmfhWORDbfType;DWORDbfSize;WORDbfReserved1;WORDbfReserved2;DWORDbfOffBits;}BITMAPFILEHEADER;typedefstructtagBITMAPINFOHEADER{//bmihDWORDbiSize;LONGbiWidth;LONGbiHeight;WORDbiPlanes;WORDbiBitCount;DWORDbiCompression;DWORDbiSizeImage;LONGbiXPelsPerMeter;LONGbiYPelsPerMeter;DWORDbiClrUsed;DWORDbiClrImportant;}BITMAPINFOHEADER;typedefstructtagRGBQUAD{//rgbqBYTErgbBlue;BYTErgbGreen;BYTErgbRed;BYTErgbReserved;}RGBQUAD;typedefstructtagBITMAPINFO{BITMAPINFOHEADERbmiHeader;RGBQUADbmiColors[1];}BITMAPINFO;#includestdio.h#includestdlib.h#includestring.h#includemalloc.h#includectype.h#includeprocess.h#include"BMP_4.h"BITMAPFILEHEADERbmfhBITMAPINFOHEADERbmihBYTEimgDatareadDataintReadFileHeaderBITMAPFILEHEADERintReadInfoHeaderBITMAPINFOHEADER;intCreatePalette(RGBQUAD);intReadPixelDataBYTE;LONGGetLineBytes(int,int);voidNeighborAveragedoubleintSaveAsImage(char*);lepathDWORDdwLineBytesdoubleprintf("InputdwLineBytes=GetLineBytes(bmih.biWidth,bmih.biBitCount);error~\n");scanf("%f",&Error);NeighborAverage(Error);printf("Saveasanotherpath(ex.d:saveasfilepathifiprintfErrorfailedton");}return0;}savetheimage.\oidreadDataintikhDWORDdwLineBytesprintfReadfileheadersuccessful~\n");}kReadInfoHeaderbmihifk{printf("Readinfoheadersuccessful~LineBytesbmihbiWidthbmihbiBitCountimgDataBYTEmallocdwLineBytes*bmih.biHeight*sizeof(BYTE));h=ReadPixelData(imgData);if(h==0){printf("Readpixeldatasuccessful~if(i==0&&k==0&&h==0){printf("Readdatassuccessful~\n");}}ERbmfhFILEdataFiledataFilefopenshuaigebmpriffread(&bmfh-bfType,sizeof(WORD),1,dataFile)~=1){printf("CannotreadbfTypeinthefileheadernfclosedataFilereturn-1;}if(fread(&bmfh-bfSize,sizeof(DWORD),1,dataFile)~=1){printf("CannotreadbfSizeinthefileheader.\n");fclose(dataFile);return-1;}if(fread(&bmfh-bfReserved1,sizeof(WORD),1,dataFile)~printfCannotreadbfReservedinthefileheader.\n");fclose(dataFile);return-1;}if(fread(&bmfh-bfReserved2,sizeof(WORD),1,dataFile)~nprintfCannotreadbfReserved2inthefileheader.\fclose(dataFile);return-1;}if(fread(&bmfh-bfOffBits,sizeof(DWORD),1,dataFile)~printfCannotreadbfOffBitsinthefileheader.\n");turnfclosedataFileturnERbmihFILEdataFilenshuaigebmprFileSEEKSETif(fread(&bmih-biSize,sizeof(DWORD),1,dataFile)~=1){printf("CannotreadbiSizeintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biWidth,sizeof(LONG),1,dataFile)~=1){printf("CannotreadbiWidthintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biHeight,sizeof(LONG),1,dataFile)~=1){printf("CannotreadbiHeightintheinfoheadernfclosedataFile);return-1;}if(fread(&bmih-biPlanes,sizeof(WORD),1,dataFile)~=1){printf("CannotreadbiPlanesintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biBitCount,sizeof(WORD),1,dataFile)~=1){printf("CannotreadbiBitCountintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biCompression,sizeof(DWORD),1,dataFile)~n");=1){printf("CannotreadbiCompressionintheinfoheader.\fclose(dataFile);return-1;}if(fread(&bmih-biSizeImage,sizeof(DWORD),1,dataFile)~n");=1){printf("CannotreadbiSizeImageintheinfoheader.\fclose(dataFile);return-1;}if(fread(&bmih-biXPelsPerMeter,sizeof(LONG),1,dataFile)~=1){printf("CannotreadbiXPelsPerMeterintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biYPelsPerMeter,sizeof(LONG),1,dataFile)~=1){printf("CannotreadbiYPelsPerMeterintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biClrUsed,sizeof(DWORD),1,dataFile)~=1){printf("CannotreadbiClrUsedintheinfoheader.\n");fclose(dataFile);return-1;}if(fread(&bmih-biClrImportant,sizeof(DWORD),1,dataFile)~=1){printf("CannotreadbiClrImportantintheinfoheader.\n");fclose(dataFile);return-1;}fclose(dataFile);turnetteRGBQUADpalintiif(sizeof(pal)/sizeof(RGBQUAD)~=256){printf("Thesizeofthepalettemustbe256.\n");return-1;}ipalirgbBlueipalirgbGreenipali].rgbRed=i;pal[i].rgbReturnTEdataFILEdataFileDWORDGetLineBytesbmihbiWidthbmihbiBitCountdataBYTEmallocdwLineBytesbmihbiHeightsizeofBYTEdataFilefopen"shuaige.bmilebmfhbfOffBitsSEEKSETif(fread(data,dwLineBytes*bmih.biHeight*sizeof(BYTE),1,dataFile)~printfCannotreadthepixeldata.\n");free(data);turnfclosedataFilememcpyimgDatadatadwLineBytesbmihbiHeight*sizeof(BYTE));free(dataFileturnetLineBytesintimgWidthintbitCountreturnimgWidthbitCount32*4;}ighborAveragedoubleErrorintdwLineBytesintNewdwLineBytesintNewHeightBYTE*NewData;doublegray;inti,j;ineBytesbmihbiWidthbmihbiBitCountNewdwLineBytetesNewHeightbmihbiHeightNewDataBYTEmallocNewdwLinizeofBYTEiNewHeightiforjjNewdwLineBytesneBytesijiibmihbiHeightiforjjdwLineBytesjNewDataNewdwLineBytesijimgDatadwLineBytesij}}foriiNewHeightiforjjNewdwLineBytesjgraydoubleNewDataNewdwLineBytes*(i-1)+j-NewDataNewdwLineBytesijjNewDataNewdwLineBytesiesijNewDataNewdwLineBytesij+wDataNewdwLineBytesijgrayErrorimgDatadwLineBytesijintgray}}}thFILEdataFileRGBQUADpalineBytesbmihbiWidthbmihbiBitCountdataFile=fopen(filepath,"wb");if(~dataFile){printf("Error:Cannotopenthefilesnfilepathreturn-1;}for(i=0;i256;ipalirgbReservedpal[i].rgbBlue=i;pal[i].rgbGreen=i;irgbRediif(fwrite(&bmfh.bfType,sizeof(WORD),1,dataFile)~=1){printf("CannotwritebfTypeinthefileheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmfh.bfSize,sizeof(DWORD),1,dataFile)~=1){printf("CannotwritebfSizeinthefileheadernfclosedataFile);return-1;}if(fwrite(&bmfh.bfReserved1,sizeof(WORD),1,dataFile)~printfCannotwritebfReservedinthefileheader.\n");taFilereturn1;}if(fwrite(&bmfh.bfReserved2,sizeof(WORD),1,dataFile)~printfCannotwritebfReservedinthefileheader.\n");taFilereturn1;}if(fwrite(&bmfh.bfOffBits,sizeof(DWORD),1,dataFile)~printfCannotwritebfOffBitsinthefileheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmih.biSize,sizeof(DWORD),1,dataFile)~=1){printf("Can notwritebiSizeintheinfoheadernfclose(dataFile);return-1;}if(fwrite(&bmih.biWidth,sizeof(LONG),1,dataFile)~=1){printf("CannotwritebiWidthintheinfoheadernfclosedataFile);return-1;}if(fwrite(&bmih.biHeight,sizeof(LONG),1,dataFile)~=1){printf("CannotwritebiHeightintheinfoheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmih.biPlanes,sizeof(WORD),1,dataFile)~){printf("CannotwritebiPlanesintheinfoheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmih.biBitCount,sizeof(WORD),1,dataFile)~){printf("CannotwritebiBitCountintheinfoheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmih.biCompression,sizeof(DWORD),1,dataFile)~){printf("CannotwritebiCompressionintheinfoheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmih.biSizeImage,sizeof(DWORD),1,dataFile)~){printf("CannotwritebiSizeImageintheinfoheader.\n");fclose(dataFile);return-1;}if(fwrite(&bmih.biXPelsPerMeter,sizeof(LONG),1,dataFile)~){printf("CannotwritebiXPels
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 一的變調(diào)練習(xí)題
- 二零二五年度重型吊車安全責(zé)任及運輸合同3篇
- 壓瘡的預(yù)防及護(hù)理課件
- 射箭游戲-數(shù)學(xué)
- 2024年浙江宇翔職業(yè)技術(shù)學(xué)院高職單招職業(yè)適應(yīng)性測試歷年參考題庫含答案解析
- 2024年濟(jì)源職業(yè)技術(shù)學(xué)院高職單招職業(yè)適應(yīng)性測試歷年參考題庫含答案解析
- 《科幻小說賞析與寫作》 課件 -第三章 “太空歌劇”的探索與開拓-《2001太空漫游》
- 2024年河南工業(yè)貿(mào)易職業(yè)學(xué)院高職單招職業(yè)技能測驗歷年參考題庫(頻考版)含答案解析
- 二零二五年租賃權(quán)轉(zhuǎn)讓及配套設(shè)備協(xié)議范本3篇
- 2024年滄州職業(yè)技術(shù)學(xué)院高職單招語文歷年參考題庫含答案解析
- 2025年中國AI AGENT(人工智能體)行業(yè)市場動態(tài)分析、發(fā)展方向及投資前景分析報告
- 家居建材行業(yè)綠色材料應(yīng)用及節(jié)能設(shè)計方
- 農(nóng)副產(chǎn)品安全培訓(xùn)
- 2024年中國玩具工程車市場調(diào)查研究報告
- 2025-2030年中國電動三輪車市場發(fā)展現(xiàn)狀及前景趨勢分析報告
- TCABEE 063-2024 建筑光儲直柔系統(tǒng)變換器 通 用技術(shù)要求
- 【9化期末】合肥市廬陽區(qū)2023-2024學(xué)年九年級上學(xué)期期末化學(xué)試題
- 高一下學(xué)期生物人教版必修二:3.4 基因通常是有遺傳效應(yīng)的DNA片段課件
- 下屬企業(yè)考核報告范文
- 修車補(bǔ)胎合同范例
- 2024年基金應(yīng)知應(yīng)會考試試題
評論
0/150
提交評論