欢迎来到天天文库
浏览记录
ID:9265848
大小:36.88 KB
页数:9页
时间:2018-04-25
《图像平滑化处理邻域平均法c语言实现》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、图像平滑化处理邻域平均法C语言实现邻域平均法是简单的空域图像平滑化处理方法,对图像噪声的去除有一定的效果。#ifndefBMP_H_4_INCLUDED#defineBMP_H_4_INCLUDEDtypedefunsignedshortWORD;typedefunsignedlongDWORD;typedeflongLONG;typedefunsignedcharBYTE;typedefstructtagBITMAPFILEHEADER{//bmfhWORDbfType;DWORDbfSize;WORDbfReserved1;WORDbfReserved2;DWORDbfOf
2、fBits;}BITMAPFILEHEADER;typedefstructtagBITMAPINFOHEADER{//bmihDWORDbiSize;LONGbiWidth;LONGbiHeight;WORDbiPlanes;WORDbiBitCount;DWORDbiCompression;DWORDbiSizeImage;LONGbiXPelsPerMeter;LONGbiYPelsPerMeter;DWORDbiClrUsed;DWORDbiClrImportant;}BITMAPINFOHEADER;typedefstructtagRGBQUAD{//rgbqBYTEr
3、gbBlue;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"BITMAPFILEHEADERbmfh;BITMAPINFOHEADERbm
4、ih;BYTE*imgData;voidreadData();intReadFileHeader(BITMAPFILEHEADER*);intReadInfoHeader(BITMAPINFOHEADER*);intCreatePalette(RGBQUAD);intReadPixelData(BYTE*);LONGGetLineBytes(int,int);voidNeighborAverage(double);intSaveAsImage(char*);intmain(){inti;charsaveasfilepath[256];DWORDdwLineBytes;doubl
5、eError;readData();dwLineBytes=GetLineBytes(bmih.biWidth,bmih.biBitCount);printf("Inputerror!");scanf("%f",&Error);NeighborAverage(Error);printf("Saveasanotherpath(ex.d://poon.bmp)");scanf("%s",saveasfilepath);i=SaveAsImage(saveasfilepath);if(i==-1){printf("Error:failedtosavetheimage.")
6、;}return0;}voidreadData(){inti,k,h;DWORDdwLineBytes;i=ReadFileHeader(&bmfh);if(i==0){printf("Readfileheadersuccessful!");}k=ReadInfoHeader(&bmih);if(k==0){printf("Readinfoheadersuccessful!");}dwLineBytes=GetLineBytes(bmih.biWidth,bmih.biBitCount);imgData=(BYTE*)malloc(dwLineBytes*bmih.bi
7、Height*sizeof(BYTE));h=ReadPixelData(imgData);if(h==0){printf("Readpixeldatasuccessful!");}if(i==0&&k==0&&h==0){printf("Readdatassuccessful!");}}intReadFileHeader(BITMAPFILEHEADER*bmfh){FILE*dataFile;dataFile=fopen("shuaige.bmp","r");if(fread(&
此文档下载收益归作者所有