資源簡介
vc++6平臺下的中值濾波c程序,附帶圖片。隨手寫的小程序。絕對可以用。

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
//原圖象的寬度和高度
#define?width?352
#define?higth?288
int?lvbo(unsigned?char?D[9])
{
unsigned?int?temp;
int?ij;
for(i=0;i<9;i++)
????for(j=0;j<9-i;j++)
if(D[i]>D[j+1])
{
???temp=D[i];
???D[i]=D[j+1];
???D[j+1]=temp;
}
return?D[4];
}
void?main()
{
FILE?*fp*newfp;
int?ij;
if(!(fp=fopen(“fmh1.bmp““rb“)))
??????{
????????printf(“Open?file?%s?error!\n““k.bmp“);
????????exit(1);
??????}
if(!(newfp=fopen(“fmout.bmp““wb“)))
??????{
????????printf(“Open?file?%s?error!\n““result.bmp“);
????????exit(1);
??????}
unsigned?char?buffer[54+1024];//定義原圖像頭緩沖區(qū)
fread(buffer154+1024fp);//讀取文件頭54個字節(jié)
unsigned?long?length=width*higth;//圖像的總象素個數(shù)
unsigned?char?readData[higth][width];???????????????//用于存儲原圖數(shù)據(jù)的數(shù)組
unsigned?char?writeData[higth][width];???????????????//用于存儲原圖數(shù)據(jù)的數(shù)組
fread(&readData[0][0]?sizeof(unsigned?char)length?fp);//從原圖讀入數(shù)據(jù)
for(i=0;i for(j=0;j ????????writeData[i][j]=readData[i][j];
??????
unsigned?char?D[9];????????//定義選取框
for(i=1;i for(j=1;j {
D[0]=readData[i-1][j+1];
????D[1]=readData[i][j+1];
D[2]=readData[i+1][j+1];
D[3]=readData[i-1][j];
D[4]=readData[i][j];
D[5]=readData[i+1][j];
D[6]=readData[i-1][j-1];
D[7]=readData[i][j-1];
D[8]=readData[i+1][j-1];
????????writeData[i][j]=lvbo(D);
}
fwrite(buffersizeof(unsigned?char)54+1024newfp);
fwrite(writeDatasizeof(unsigned?char)lengthnewfp);
fclose(newfp);
fclose(fp);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????102456??2008-06-05?19:10??中值濾波\1.bmp
?????文件?????102454??2009-09-02?20:55??中值濾波\2.bmp
?????文件???????1722??2009-12-03?22:48??中值濾波\Cpp1.cpp
?????文件???????3377??2008-12-22?21:28??中值濾波\Cpp1.dsp
?????文件????????516??2008-12-22?21:30??中值濾波\Cpp1.dsw
?????文件??????50176??2009-12-03?22:50??中值濾波\Cpp1.ncb
?????文件??????48640??2009-12-03?22:50??中值濾波\Cpp1.opt
?????文件???????1119??2009-12-03?22:48??中值濾波\Cpp1.plg
?????文件?????180281??2009-12-03?22:48??中值濾波\Debug\Cpp1.exe
?????文件??????14248??2009-12-03?22:48??中值濾波\Debug\Cpp1.obj
?????文件?????558080??2009-12-03?22:48??中值濾波\Debug\Cpp1.pdb
?????文件?????118784??2009-12-03?22:48??中值濾波\Debug\vc60.pdb
?????文件?????102454??2009-12-03?21:26??中值濾波\fmh1.bmp
?????文件?????102454??2009-12-03?22:49??中值濾波\fmout.bmp
?????目錄??????????0??2009-12-05?17:37??中值濾波\Debug
?????目錄??????????0??2009-12-05?17:37??中值濾波
-----------?---------??----------?-----??----
??????????????1386761????????????????????16
評論
共有 條評論