【正文】
dataFile=fopen(filepath,wb);if(!dataFile){printf(Error:Can not open the file:%s\n,filepath);return1;}for(i=0;i 256;i++){pal[i].rgbReserved=0;pal[i].rgbBlue=i;pal[i].rgbGreen=i;pal[i].rgbRed=i;}if(fwrite(amp。,sizeof(LONG),1,dataFile)!=1){printf(Can not write biHeight in the info header.\n);fclose(dataFile);return1;}if(fwrite(amp。,sizeof(DWORD),1,dataFile)!=1){printf(Can not write biClrImportant in the info header.\n);fclose(dataFile);return1;}if(==8){if(fwrite(pal,sizeof(RGBQUAD),256,dataFile)!=256){printf(Error:can not write the color palette.\n);fclose(dataFile);return1;}}if(fwrite(imgData,*dwLineBytes,1,dataFile)!=1){printf(Error:can not write the pixel data.\n);fclose(dataFile);return1;}fclose(dataFile);printf(Save As the image successfully.\n);return 0;}運用程序?qū)?位位圖進行直方圖均衡化處理,結(jié)果如下:原圖變換后圖像。,sizeof(WORD),1,dataFile)!=1){printf(Can not write biBitCount in the info header.\n);fclose(dataFile);return1;}if(fwrite(amp。,sizeof(DWORD),1,dataFile)!=1){printf(Can not write bfSize in the file header.\n);fclose(dataFile);return1;}if(fwrite(amp。bmihbiBitCount,sizeof(WORD),1,dataFile)!=1){printf(Can not read biBitCount in the info header.\n);fclose(dataFile);return1;}if(fread(amp。bmfhbfSize,sizeof(DWORD),1,dataFile)!=1){printf(Can not read bfSize in the file header.\n);fclose(dataFile);return1;}if(fread(amp。圖像增強 直方圖均衡化處理C語言實現(xiàn)ifndef BMP_H_3_INCLUDEDdefine BMP_H_3_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 struc