版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、BMP圖像差分C語(yǔ)言程序:#include <stdio.h>#include <stdlib.h>typedef unsigned short WORD;typedef unsigned long DWORD;typedef long LONG;typedef unsigned char BYTE;typedef struct BITMAPFILEHEADER WORD bfType;
2、60; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffbits; BITMAPFILEHEADER,*PBITMAPFILEHEADER;t
3、ypedef struct BITMAPINFOHEADER DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes;
4、160; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPlesPerMeter;
5、LONG biYPlesPerMeter; DWORD biClrUsed; DWORD biClrImportant; BITMAPINFOHEADER,*PBITMAPINFOHEADER;typedef struct RGBQUAD &
6、#160; BYTE rgbBlue; BYTE rgbGreen; BYTE rgbRed; BYTE rgbReserved; RGBQUAD;int main(int argc,char *argv
7、) BITMAPFILEHEADER mapfileheader; BITMAPINFOHEADER mapinfoheader; DWORD bfSize1=0; DWORD bfSize2; DWORD bfOffbits1; DWOR
8、D bfOffbits2; DWORD biWidth1; DWORD biWidth2; DWORD biHeight1; DWORD biHeight2; WORD biBitCount1; WORD biBitCount2;
9、; LONG biXPlesPerMeter1; LONG biXPlesPerMeter2; LONG biYPlesPerMeter1; LONG biYPlesPerMeter2; BYTE a; BYTE b;
10、; BYTE c; FILE *fp1=0; FILE *fp2=0; FILE *fpa=0; FILE *fpb=0; DWORD line_bytes1; DWORD line_bytes2;
11、160; BYTE *pixel1; BYTE *pixel2; BYTE *pixel3; int i=0; int j=0; RGBQUAD pal256; int ret1;
12、 int ret2; if(argc!=3) printf("Please input the path of the file.n"); return 1; fp1=f
13、open(argv1,"rb"); if(!fp1) printf("Cannot open the first file.n"); return 1; fp2=fopen(argv2,
14、"rb"); if(!fp2) printf("Cannot open the second file.n"); return 1; fseek(fp1,10,SEEK_SE
15、T); fseek(fp2,10,SEEK_SET); if(fread(&bfOffbits1,4,1,fp1)!=1) printf("Cannot read bfOffbits of the head of the first file.n");
16、60; fclose(fp1); fclose(fp2); return 1; printf("bfOffbits1:%
17、dn",bfOffbits1); if(fread(&bfOffbits2,4,1,fp2)!=1) printf("Cannot read bfOffbits of the head of the second file.n");
18、160; fclose(fp1); fclose(fp2); return 1; printf("bfOffbits2:%dn",bfOffbit
19、s2); fseek(fp1,18,SEEK_SET); fseek(fp2,18,SEEK_SET); if(fread(&biWidth1,4,1,fp1)!=1) printf("Cannot read
20、 biWidth of the head of the first file.n"); fclose(fp1); fclose(fp2); return 1;
21、 printf("biWidth1:%dn",biWidth1); if(fread(&biWidth2,4,1,fp2)!=1) printf("Cannot read biWidth of the head of se
22、cond file.n"); fclose(fp1); fclose(fp2); return 1;
23、0; printf("biWidth2:%dn",biWidth2); if(fread(&biHeight1,4,1,fp1)!=1) printf("Cannot read biHeight1 of the head.n");
24、0; fclose(fp1); fclose(fp2); return 1; printf("biHeight1:%dn
25、",biHeight1); if(fread(&biHeight2,4,1,fp2)!=1) printf("Cannot read biHeight2 of the head.n"); &
26、#160; fclose(fp1); fclose(fp2); return 1; printf("biHeight2:%dn",biHeight2);
27、60; fseek(fp1,28,SEEK_SET); fseek(fp2,28,SEEK_SET); if(fread(&biBitCount1,2,1,fp1)!=1) printf("Cannot read biBitCount1 of the he
28、ad.n"); fclose(fp1); fclose(fp2); return 1;
29、; printf("biBitCount1:%dn",biBitCount1); if(fread(&biBitCount2,2,1,fp2)!=1) printf("Cannot read biBitCount2 of the head.n");
30、 fclose(fp1); fclose(fp2); return 1; printf("biBItCoun
31、t2:%dn",biBitCount2); if(biBitCount1!=biBitCount2) printf("Two picutres have different biBitCount.n");
32、160; fclose(fp1); fclose(fp2); return 1; fseek(fp1,sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER),
33、SEEK_SET); fseek(fp2,sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER),SEEK_SET); for(i=0;i<255;i+) fread(&pali.rgbBlue,1,1,fp1); &
34、#160; fread(&pali.rgbGreen,1,1,fp1); fread(&pali.rgbRed,1,1,fp1); pali.rgbReserved=0;
35、160; line_bytes1=(biWidth1*biBitCount1+31)/32*4; line_bytes2=(biWidth2*biBitCount2+31)/32*4; pixel1=(BYTE*)malloc(biHeight1*line_bytes1*si
36、zeof(BYTE); memset(pixel1,0,biHeight1*line_bytes1*sizeof(BYTE); if(pixel1=0) printf("Fail to allocate memory to File one.n");
37、160; fclose(fp1); fclose(fp2); return 1; pixel2=(BYTE*)malloc(biHeight2*line_
38、bytes2*sizeof(BYTE); memset(pixel2,0,biHeight2*line_bytes2*sizeof(BYTE); if(pixel2=0) printf("Fail to allocate memory to File two.n");
39、; fclose(fp1); fclose(fp2); return 1; pixel3=(BYTE*)malloc(biHeig
40、ht2*line_bytes2*sizeof(BYTE); memset(pixel3,0,biHeight1*line_bytes1*sizeof(BYTE); printf("an"); fseek(fp1,bfOf
41、fbits1,SEEK_SET); fseek(fp2,bfOffbits2,SEEK_SET); if(fread(pixel2,biHeight1*line_bytes1*sizeof(BYTE),1,fp2)=0)
42、60; printf("Cannot read pixels of the file two.n"); free(pixel2); pixel2=NULL;
43、160; fclose(fp1); fclose(fp2); return 1; if(fread(pixel1,biHeight2*line_bytes2*sizeof(BYTE),1,fp1)=0)
44、 printf("Cannot read pixels of the file one.n"); free(pixel1); pixe
45、l1=NULL; fclose(fp1); fclose(fp2); return 1; printf("a
46、n"); if(biBitCount1=8) printf("an"); for(i=0;i<biHeight1;i+)
47、; for(j=0;j<biWidth1;j+) &
48、#160; a=line_bytes1*i+j; if(pixel1a-pixel2a=0)
49、160; pixel3a=0;
50、160; else
51、160; pixel3a=pixel2a;
52、60;
53、 printf("an"); else printf("Only support 8 or 24 bits Bitmap.n");
54、60; free(pixel1); pixel1=NULL; free(pixel2); pixel2=NULL; fclose(fp1);
55、160; fclose(fp2); return 1; fclose(fp1); fclose(fp2); free(pixel1);
56、0; free(pixel2); pixel1=NULL; pixel2=NULL; mapfileheader.bfType=19778; mapfileheader.bfSize=bfSize1; mapfileheader.bfReserved1=0;
57、60; mapfileheader.bfReserved2=0; mapfileheader.bfOffbits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*256; mapinfoheader.biSize=sizeof(BITMAPINFOHEADER); mapinfoheader.biW
58、idth=biWidth1; mapinfoheader.biHeight=biHeight1; mapinfoheader.biPlanes=1; mapinfoheader.biBitCount=biBitCount1; mapinfoheader.biCompression=0; mapinf
59、oheader.biSizeImage=biHeight1*line_bytes1; mapinfoheader.biXPlesPerMeter=0; mapinfoheader.biYPlesPerMeter=0; mapinfoheader.biClrUsed=0; mapinfoheader.biClrImportant=0; &
60、#160; fpa=fopen("E:/Win_TC/File/test.bmp","wb"); fclose(fpa); /*fpb=fopen("E:Win-TCFiletest.bmp","wb"); if(!fpb)
61、60; printf("Cannot creat a new file.n"); return 1; fwrite(&mapfileheader,sizeof(BITMAPFILEHEADER),1
62、,fpb); fwrite(&mapinfoheader,sizeof(BITMAPINFOHEADER),1,fpb); fwrite(pal,sizeof(RGBQUAD),256,fpb); fwrite(pixel3,sizeof(BYTE)*line_bytes1*biHeight1,1,fpb); fclose(fpb);*/
63、 printf("Success."); getch(); return 0; #include <stdio.h> #include <cv.h>#include <cxcore.h>#include <highgui.h> int main( int argc, char* argv ) /聲明IplImage指針 IplImage* pFrame = NULL; IplImage* pFrImg = NULL; IplImage* pBkImg = NULL; CvMat* pFrameMat = NULL; CvMat* pFrMat = NULL; CvMat* pBkMat = N
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度房東房屋租賃合同(含綠化維護(hù)費(fèi))3篇
- 2024消防安全管理服務(wù)協(xié)議版B版
- 2024深圳技術(shù)研發(fā)合作合同
- 2025年度安防系統(tǒng)設(shè)計(jì)與施工一體化合同
- 2024版堰塘施工合同
- 《邵陽(yáng)學(xué)院合同管理辦法》
- 二零二五年度換熱站安全運(yùn)行與事故應(yīng)急預(yù)案合同3篇
- 2024毛陽(yáng)中心學(xué)校校車(chē)運(yùn)營(yíng)及安全管理合同3篇
- 2025版建筑廢棄物運(yùn)輸合同補(bǔ)充協(xié)議3篇
- 二零二五年度店面租賃與形象設(shè)計(jì)合同3篇
- 中試部培訓(xùn)資料
- 2024政務(wù)服務(wù)綜合窗口人員能力與服務(wù)規(guī)范考試試題
- JT∕T 1477-2023 系列2集裝箱 角件
- 《陸上風(fēng)電場(chǎng)工程設(shè)計(jì)概算編制規(guī)定及費(fèi)用標(biāo)準(zhǔn)》(NB-T 31011-2019)
- 22部能夠療傷的身心靈療愈電影
- 領(lǐng)導(dǎo)干部有效授權(quán)的技巧與藝術(shù)課件
- DB37-T 1915-2020 安全生產(chǎn)培訓(xùn)質(zhì)量控制規(guī)范-(高清版)
- 幼兒園“值日生”工作開(kāi)展論文
- 光伏電站繼電保護(hù)運(yùn)行規(guī)程
- 承兌匯票臺(tái)帳模版
- 地下管道頂管施工方案(非常全)
評(píng)論
0/150
提交評(píng)論