欢迎来到天天文库
浏览记录
ID:40525139
大小:31.69 KB
页数:12页
时间:2019-08-04
《BMP图像分割C语言程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、BMP图像差分C语言程序:#include#includetypedefunsignedshortWORD;typedefunsignedlongDWORD;typedeflongLONG;typedefunsignedcharBYTE;typedefstructBITMAPFILEHEADER{ WORDbfType; DWORDbfSize; WORDbfReserved1; WORDbfReserved2; DWORDbfOffbits;
2、 }BITMAPFILEHEADER,*PBITMAPFILEHEADER;typedefstructBITMAPINFOHEADER{ DWORDbiSize; LONGbiWidth; LONGbiHeight; WORDbiPlanes; WORDbiBitCount; DWORDbiCompression; DWORDbiSizeImage; LONGbiXPlesPerMeter; LONGbiYPlesP
3、erMeter; DWORDbiClrUsed; DWORDbiClrImportant; }BITMAPINFOHEADER,*PBITMAPINFOHEADER;typedefstructRGBQUAD{ BYTErgbBlue; BYTErgbGreen; BYTErgbRed; BYTErgbReserved; }RGBQUAD;intmain(intargc,char**argv){ BITMAPFILEHEADERmapf
4、ileheader; BITMAPINFOHEADERmapinfoheader; DWORDbfSize1=0; DWORDbfSize2; DWORDbfOffbits1; DWORDbfOffbits2; DWORDbiWidth1; DWORDbiWidth2; DWORDbiHeight1; DWORDbiHeight2; WORDbiBitCount1; WORDbiBitCount2; LONGbiXPlesPerMeter1; LON
5、GbiXPlesPerMeter2; LONGbiYPlesPerMeter1; LONGbiYPlesPerMeter2; BYTEa; BYTEb; BYTEc; FILE*fp1=0; FILE*fp2=0; FILE*fpa=0; FILE*fpb=0; DWORDline_bytes1; DWORDline_bytes2; BYTE*pixel1; BYTE*pixel2; BYTE*pixel3; inti=0;
6、intj=0; RGBQUADpal[256]; intret1; intret2; if(argc!=3) { printf("Pleaseinputthepathofthefile."); return1; } fp1=fopen(argv[1],"rb"); if(!fp1) { printf("Cannotopenthefirstfile."); return1; } fp2=fopen(argv[2],"rb")
7、; if(!fp2) { printf("Cannotopenthesecondfile."); return1; } fseek(fp1,10,SEEK_SET); fseek(fp2,10,SEEK_SET); if(fread(&bfOffbits1,4,1,fp1)!=1) { printf("CannotreadbfOffbitsoftheheadofthefirstfile."); fclose(fp1);
8、 fclose(fp2); return1; } pri
此文档下载收益归作者所有