




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、BMP圖像差分C語言程序:#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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030年中國鐵路機(jī)車車輛配件制造行業(yè)十三五規(guī)劃及發(fā)展前景分析報(bào)告
- 2025-2030年中國金屬鉍行業(yè)運(yùn)行現(xiàn)狀及發(fā)展前景分析報(bào)告
- 2025-2030年中國過氧化氫行業(yè)市場運(yùn)行動態(tài)與營銷策略研究報(bào)告
- 2025-2030年中國調(diào)壓器市場運(yùn)行現(xiàn)狀及發(fā)展前景預(yù)測報(bào)告
- 2025-2030年中國空氣清新機(jī)行業(yè)運(yùn)行現(xiàn)狀及發(fā)展趨勢預(yù)測報(bào)告
- 貴州工程應(yīng)用技術(shù)學(xué)院《運(yùn)動醫(yī)務(wù)監(jiān)督與康復(fù)治療》2023-2024學(xué)年第二學(xué)期期末試卷
- 2025年海南省安全員《B證》考試題庫
- 2025年建筑安全員B證考試題庫
- 山東現(xiàn)代學(xué)院《建筑設(shè)備CAD》2023-2024學(xué)年第二學(xué)期期末試卷
- 朔州師范高等??茖W(xué)?!峨姽y試技術(shù)(上)》2023-2024學(xué)年第二學(xué)期期末試卷
- 2024初中數(shù)學(xué)課程標(biāo)準(zhǔn)測試題(含答案)精華版
- XXXXX醫(yī)院腎友會活動方案
- 隧道施工重大危險(xiǎn)源辨識
- 考試通用答題卡word模板
- 環(huán)境監(jiān)理業(yè)務(wù)手冊(word)
- 人文關(guān)懷與優(yōu)質(zhì)護(hù)理課件
- 知識圖譜可視化-Neo4j(windows)
- 光伏電站作業(yè)危險(xiǎn)點(diǎn)分析及預(yù)控措施手冊
- 2021年深圳實(shí)驗(yàn)學(xué)校初中部七年級入學(xué)分班考試數(shù)學(xué)試卷及答案解析
- 水文流量測驗(yàn)
- 合作共贏商務(wù)合作PPT模板(基礎(chǔ)教育)
評論
0/150
提交評論