资源描述:
《数字图象处理实验.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、数字图象处理实验报告学院:京江学院专业班级:计算机科学与技术0701学号:3071110026姓名:孙艺铭日期:2010年6月11日实验一1.实验内容将一副彩色图像先处理成灰度图,再处理成直方图2.实验目的了解将一副彩色图像现转换成灰度图,再处理成直方图的方法,掌握程序的思想3.实验要求熟练运用VC++编写程序;4.实验源程序#include#include#include#include#include#defineWIDTHBYTES(bits)
2、(((bits)+31)/32*4)typedefunsignedcharBYTE;typedefunsignedshortWORD;typedefunsignedlongDWORD;typedeflongLONG;typedefstructtagBITMAPFILEHEADER{WORDfileType;DWORDbfSize;WORDbfReserved1;WORDbfReserved2;DWORDbfOffBits;}BITMAPFILEHEADER;//定义文件头结构体typedefstructtagBITMAPINFOHEADER
3、{DWORDbiSize;LONGbiWidth;LONGbiHeight;WORDbiPlanes;WORDbiBitCount;DWORDbiCompression;DWORDbiSizeImage;LONGbiXPelsPerMeter;LONGbiYPelsPerMeter;DWORDbiClrUsed;DWORDbiClrImportant;}BITMAPINFOHEADER;//定义信息头结构voidshowBmpHead(BITMAPFILEHEADER*pBmpHead){printf("head:");printf("
4、fileType:%d",pBmpHead->fileType);printf("bfsize:%d",pBmpHead->bfSize);printf("bfreserved1:%d",pBmpHead->bfReserved1);printf("bfreserved2:%d",pBmpHead->bfReserved2);printf("bfoffbits:%d",pBmpHead->bfOffBits);}//显示文件头信息voidshowBmpInforHead(BITMAPINFOHEADER*pBmpInfo
5、rHead){printf("head:");printf("bisize:%d",pBmpInforHead->biSize);printf("biwidth:%d",pBmpInforHead->biWidth);printf("biheight:%d",pBmpInforHead->biHeight);printf("biPlanes:%d",pBmpInforHead->biPlanes);printf("biBitCount:%d",pBmpInforHead->biBitCount);printf("bi
6、comression:%d",pBmpInforHead->biCompression);printf("biSizeImage:%d",pBmpInforHead->biSizeImage);printf("bixpelspermeter:%d",pBmpInforHead->biXPelsPerMeter);printf("biypelspermeter:%d",pBmpInforHead->biYPelsPerMeter);printf("biclrused:%d",pBmpInforHead->biClrUsed
7、);printf("biclrimportant:%d",pBmpInforHead->biClrImportant);}//显示信息头信息voidmain(){longnData;inti,j;intk;intindex;intheight;intl_width,width;BITMAPFILEHEADERbitHead;BITMAPINFOHEADERbitInfoHead;FILE*pfile;FILE*pfile1;floatcount[256],n=0;floatcount1[256],n1=0,count2[256];uns
8、ignedcharch1,ch2,ch3,ch4;charstrFile[20],strFile1[20];printf("pleaseinputthe.bmpfilename: