floating point overflow 問題 |
答題得分者是:taishyang
|
eulor2000
一般會員 發表:51 回覆:34 積分:17 註冊:2008-11-18 發送簡訊給我 |
引述 本文中http://delphi.ktop.com.tw/board.php?cid=168&fid=921&tid=64737
所提NCC 演算法程式 我實作後卻出現下列問題 我是bcb新手連debug 還不會請板上高手指點.....thanks 程式碼如下 Graphics::TBitmap *bmp1=new Graphics::TBitmap(); Graphics::TBitmap *bmp2=new Graphics::TBitmap(); bmp1->Assign(Image1->Picture->Bitmap); bmp1->PixelFormat=pf24bit; bmp1->Width=Image1->Width; bmp1->Height=Image1->Height; bmp2->PixelFormat=pf24bit; bmp2->Assign(Image2->Picture->Bitmap); bmp2->Width=Image2->Width; bmp2->Height=Image2->Height; int M,N,K,L; M=Image1->Height; N=Image1->Width; K=Image2->Height; L=Image2->Width; double w=0; static double G[30][30]; Byte *ptr; for(int y=0; y ptr = (Byte*)bmp2->ScanLine[y]; for(int x=0; x w = (double)(ptr[x] ptr[x 1] ptr[x 2])/3; G[x/3][y] = (double)(ptr[x] ptr[x 1] ptr[x 2])/3; } } w /= ( K*L ); static double F[400][400]; for(int y=0; y ptr = (Byte*)bmp1->ScanLine[y]; for(int x=0; x } double a=0; double b=0; long double c=0; double f=0; static double C[400-30][400-30]={0}; double max=0; for(int j=0; j for(int i=0;i<(N-L);i ) { f=0; for(int y=j; y<(j K); y ) { for(int x=i; x<(i L); x ) f =F[x][y]; f/=(K*L); } for(int y=-30;y<=30;y ) { for(int x=-30;x<=30;x ) { a = (G[x][y] - w)*(F[x i][y j] - f); b = (G[x][y] - w)*(G[x][y] - w); c = (F[x i][y j] - f)*(F[x i][y j] - f);---------------->停在此行 } } C[i][j] = a/( sqrt(b)*sqrt(c) 0.00001 ); // if(C[i][j]>=max) max=C[i][j]; } } |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
eulor2000
一般會員 發表:51 回覆:34 積分:17 註冊:2008-11-18 發送簡訊給我 |
感謝副板大提醒....經爬文後看到這篇文章 http://delphi.ktop.com.tw/board.php?cid=168&fid=1499&tid=92544
修改後 程式如下還是同樣錯誤..... bmp2->PixelFormat=pf24bit; bmp2->Assign(Image2->Picture->Bitmap); bmp2->Width=Image2->Width; bmp2->Height=Image2->Height; int M,N,K,L; M=Image1->Height; N=Image1->Width; K=Image2->Height; L=Image2->Width; double w=0; static double G[30][30]; Byte *ptr; for(int y=0; y ptr = (Byte*)bmp2->ScanLine[y]; for(int x=0; x w = (double)(ptr[x] ptr[x 1] ptr[x 2])/3; G[x/3][y] = (double)(ptr[x] ptr[x 1] ptr[x 2])/3; } } w /= ( K*L ); static double F[400][400]; for(int y=0; y ptr = (Byte*)bmp1->ScanLine[y]; for(int x=0; x } double a=0; double b=0; long double c=0; double f=0; static double C[400-30][400-30]={0}; double max=0; for(int j=0; j for(int i=0;i<(N-L);i ) { f=0; for(int y=j; y<(j K); y ) { for(int x=i; x<(i L); x ) f =F[x][y]; f/=(K*L); } for(int y=0;y<=30;y ) { for(int x=0;x<=30;x ) { a = (G[x][y] - w)*(F[x i][y j] - f); b = (G[x][y] - w)*(G[x][y] - w); c = (F[x i][y j] - f)*(F[x i][y j] - f); } } if(b<0.0001) //自訂精確度 b=0.0001; if(c<0.0001) c=0.0001; C[i][j] = a/( sqrt(b)*sqrt(c) 0.0001); //----->錯誤在此行 if(C[i][j]>=max) max=C[i][j]; } } |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
istillloving
高階會員 發表:33 回覆:182 積分:183 註冊:2008-10-09 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |