From d78eec7726a69dfad5cbf2867fad1803fcc7f427 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@c-s.fr> Date: Fri, 7 Dec 2007 15:37:03 +0000 Subject: [PATCH] =?UTF-8?q?Correction=20pr=C3=A9cision=20des=20calculs=20?= =?UTF-8?q?=C3=A0=20l'int=C3=A9rieur=20du=20filtre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../otbImageToPathListAlignFilter.h | 7 ++-- .../otbImageToPathListAlignFilter.txx | 38 +++++++++---------- .../FeatureExtraction/otbAlignImageToPath.cxx | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Code/FeatureExtraction/otbImageToPathListAlignFilter.h b/Code/FeatureExtraction/otbImageToPathListAlignFilter.h index 0349129984..0f5009a884 100644 --- a/Code/FeatureExtraction/otbImageToPathListAlignFilter.h +++ b/Code/FeatureExtraction/otbImageToPathListAlignFilter.h @@ -69,8 +69,9 @@ public: typedef typename Superclass::OutputPathPointerType OutputPathPointerType; // typedef float RealType; - typedef typename itk::NumericTraits<PixelType>::RealType RealType; -// typedef typename itk::Image<RealType,InputImageDimension> RealImageType; + //typedef typename itk::NumericTraits<PixelType>::RealType RealType; + typedef double RealType; +// typedef typename itk::Image<RealType,InputImageDimension> RealImageType; typedef typename otb::Image<RealType,InputImageDimension> RealImageType; typedef typename RealImageType::Pointer RealImageTypePointer; typedef typename RealImageType::IndexType RealImageTypeIndexType; @@ -141,7 +142,7 @@ private: int m_NbLineDirection; /// Number of line directions to scan, default 96) double m_MinGradNorm; /// Minimum gradient norm to define a direction, default 2. double m_Eps; /// -log10(max. number of false alarms), default 0 - std::vector<float> m_seglist; + std::vector<double> m_seglist; RealImageType * m_AngleImage; //Angle image use by GenerateData and AngleCalculate methods }; diff --git a/Code/FeatureExtraction/otbImageToPathListAlignFilter.txx b/Code/FeatureExtraction/otbImageToPathListAlignFilter.txx index d221d61e11..b0dafa4048 100644 --- a/Code/FeatureExtraction/otbImageToPathListAlignFilter.txx +++ b/Code/FeatureExtraction/otbImageToPathListAlignFilter.txx @@ -222,7 +222,7 @@ void ImageToPathListAlignFilter<TInputImage,TOutputPath> ::AngleCalculate(const InputImageType* InputImage) { - float threshold; + double threshold; int n,p,x,y; typename InputImageType::SizeType Taille; @@ -322,15 +322,15 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> double nfa,max_nfa; std::vector<double> test; std::vector<int> count,startbloc,endbloc; - std::vector<float> seglist; /* list of recorded segments */ + std::vector<double> seglist; /* list of recorded segments */ std::vector<one_segment> seg; int mx,my,ox,oy,nx,ny,n; int xx,yy,pos,posmax,nblocs,inbloc,max_nblocs; int cur,i,j,side,l,lphase; // int tmp; int itheta,ntheta; - float theta,theta0,dtheta,dx,dy,prec; - float error =0.0; + double theta,theta0,dtheta,dx,dy,prec; + double error =0.0; itkDebugMacro(<< "ImageToPathListAlignFilter::GenerateData() called"); @@ -360,9 +360,9 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> test = tab(n,1.0/(double)(m_NbGradDirection),(double)(nx*ny)*(double)(nx*ny)); /*** initialization ***/ - prec = M_PI/(float)(m_NbGradDirection); + prec = M_PI/(double)(m_NbGradDirection); ntheta = m_NbLineDirection/2; /* i.e. # directions of NON-ORIENTED lines */ - dtheta = M_PI/(float)ntheta; + dtheta = M_PI/(double)ntheta; /******************** memory allocation ********************/ @@ -400,9 +400,9 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> for (itheta = 0; itheta<ntheta; itheta++) { printf("."); fflush(stdout); - theta = theta0 + (float)(itheta)*dtheta; - dx = (float)vcl_cos((double)theta); - dy = (float)vcl_sin((double)theta); + theta = theta0 + (double)(itheta)*dtheta; + dx = (double)vcl_cos((double)theta); + dy = (double)vcl_sin((double)theta); /*** third loop : start positions ***/ for (pos=0;pos<posmax;pos++) { @@ -415,8 +415,8 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> /*** detect aligned points by blocs ***/ inbloc = nblocs = cur = l = count[0] = 0; - xx = ox+pos*mx + (int)(dx*(float)(l*2+lphase)); - yy = oy+pos*my + (int)(dy*(float)(l*2+lphase)); + xx = ox+pos*mx + (int)(dx*(double)(l*2+lphase)); + yy = oy+pos*my + (int)(dy*(double)(l*2+lphase)); for (;xx>=0 && xx<nx && yy>=0 && yy<ny;) { @@ -428,7 +428,7 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> assert( indexAngle[0] >= 0 ); assert( indexAngle[1] >= 0 ); - error = static_cast<float>( m_AngleImage->GetPixel(indexAngle) ); + error = static_cast<double>( m_AngleImage->GetPixel(indexAngle) ); if (error>-100.0) { error -= theta; while (error<=-M_PI) error += 2.0*M_PI; @@ -451,8 +451,8 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> } /* compute next point */ l++; - xx = ox+pos*mx + (int)(dx*(float)(l*2+lphase)); - yy = oy+pos*my + (int)(dy*(float)(l*2+lphase)); + xx = ox+pos*mx + (int)(dx*(double)(l*2+lphase)); + yy = oy+pos*my + (int)(dy*(double)(l*2+lphase)); } /*** detect meaningful segments ***/ @@ -494,11 +494,11 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath> /*** store detected segments ***/ for (i=0;i<iseg;i++) if (seg[i].ok) { - seglist[iseglist*5 ]=(float)(ox+pos*mx)+dx*(float)(seg[i].start); - seglist[iseglist*5+1]=(float)(oy+pos*my)+dy*(float)(seg[i].start); - seglist[iseglist*5+2]=(float)(ox+pos*mx)+dx*(float)(seg[i].end); - seglist[iseglist*5+3]=(float)(oy+pos*my)+dy*(float)(seg[i].end); - seglist[iseglist*5+4]=-(float)log10(seg[i].nfa); + seglist[iseglist*5 ]=(double)(ox+pos*mx)+dx*(double)(seg[i].start); + seglist[iseglist*5+1]=(double)(oy+pos*my)+dy*(double)(seg[i].start); + seglist[iseglist*5+2]=(double)(ox+pos*mx)+dx*(double)(seg[i].end); + seglist[iseglist*5+3]=(double)(oy+pos*my)+dy*(double)(seg[i].end); + seglist[iseglist*5+4]=-(double)log10(seg[i].nfa); iseglist++; /* reallocate seglist if necessary */ if (iseglist==size_seglist) { diff --git a/Testing/Code/FeatureExtraction/otbAlignImageToPath.cxx b/Testing/Code/FeatureExtraction/otbAlignImageToPath.cxx index 6b1744c7d9..de48e979c9 100644 --- a/Testing/Code/FeatureExtraction/otbAlignImageToPath.cxx +++ b/Testing/Code/FeatureExtraction/otbAlignImageToPath.cxx @@ -113,7 +113,7 @@ int otbAlignImageToPath( int argc, char * argv[] ) cindex = vertexList->GetElement(1); x2 = cindex[0]; y2 = cindex[1]; - fprintf(file,"%8.4f %8.3f\n",x1,y1); + fprintf(file,"%8.3f %8.3f\n",x1,y1); } fclose(file); -- GitLab