




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
現(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)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 南通師范高等專科學?!妒覂仍O計原理》2023-2024學年第二學期期末試卷
- 湖南省株洲市攸縣2025屆三下數(shù)學期末統(tǒng)考模擬試題含解析
- 山西省呂梁市汾陽市2025屆初三下學期升級統(tǒng)測英語試題含答案
- 江蘇如皋市江安鎮(zhèn)中心中學2024-2025學年高三第三次適應性訓練物理試題含解析
- 石嘴山工貿職業(yè)技術學院《中國傳統(tǒng)文化》2023-2024學年第二學期期末試卷
- 西安財經大學行知學院《外科學(外??疲?023-2024學年第二學期期末試卷
- 中國海洋大學《醫(yī)療儀器設計》2023-2024學年第二學期期末試卷
- 四川華新現(xiàn)代職業(yè)學院《工程熱力學D》2023-2024學年第二學期期末試卷
- 南充職業(yè)技術學院《心靈導航》2023-2024學年第二學期期末試卷
- 帳戶的分類的類型及含義
- 銀行內控案防警示教育
- 2025-2030中國鍍鋅鋼板行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 施工合同中約定的安全防護、文明施工措施費用支付計劃
- 2025年安陽職業(yè)技術學院單招職業(yè)傾向性測試題庫帶答案
- 2025年審計監(jiān)察面試題及答案
- nginx面試題及答案100道
- 2022年學校財務工作自查總結
- 湖北省武漢市洪山區(qū)2023-2024學年八年級下學期期中考試物理試題
- 天津市新版就業(yè)、勞動合同登記名冊
- EHS績效指標數(shù)字化設定-事件比率
- 基于PLC的電梯控制系統(tǒng)設計畢業(yè)論文
評論
0/150
提交評論