文档详情

用 c 语言进行数字图像处理.doc

发布:2018-09-29约1.97万字共19页下载文档
文本预览下载声明
用 c 语言进行数字图像处理 其实,数字图像处理有几步呢?一共三步。第一步,读入图片。第二步,处理图片。第三步,保存图片 。 而第二步主要涉及的是处理图像的算法,所以,我在这里就不多说了。而第一步和第三步是为第二步做 位图文件结构的声明:BMP.h #ifndef BMP_H_INCLUDED #define BMP_H_INCLUDED typedef unsigned short WORD; typedef unsigned long DWORD; typedef long LONG; typedef unsigned char BYTE; typedef struct tagBITMAPFILEHEADER { // bmfh WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; }BITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER { // bmih DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; }BITMAPINFOHEADER; typedef struct tagRGBQUAD { // rgbq BYTE rgbBlue; BYTE rgbGreen; BYTE rgbRed; BYTE rgbReserved; }RGBQUAD; typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; }BITMAPINFO; #endif // BMP_H_INCLUDED 主程序:main.c #include stdio.h #include stdlib.h #include string.h #include malloc.h #include ctype.h #include process.h #include BMP.h BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; BYTE *imgData; bool bReadBMFH=false; bool bReadBMIH=false; bool bReadPixel=false; //检查路径是否合法:文件能打开;以 bmp 为后缀名 int CheckFilePath(char *filepath); //读入位图的文件头 int ReadFileHeader(char *filepath,BITMAPFILEHEADER *bmfh); //打印位图的文件头 void PrintFileHeader(BITMAPFILEHEADER *bmfh); //读入位图的信息头 int ReadInfoHeader(char *filepath,BITMAPINFOHEADER *bmih); //打印位图的信息头 void PrintInfoHeader(BITMAPINFOHEADER *bmih); //创建 8 位位图的调色板 int CreatePalette(RGBQUAD pal[]); //读入位图的像素数据 int ReadPixelData(char *filepath,BYTE *imgData); //计算每行像素所占的字节数 LONG GetLineBytes(int imgWidth,int bitCount); //打印位图的像素数据 void PrintPixelData(BYTE *imgData,int width,int height,int bitCount); //打印菜单选项 void PrintMenu(
显示全部
相似文档