From b7709d86eb106f958fa28bf88233ae6bec831dff Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@orfeo-toolbox.org> Date: Wed, 10 May 2006 09:06:06 +0000 Subject: [PATCH] Mise en commentaire dans PixelSuppression --- .../FeatureExtraction/otbLocalHoughFilter.txx | 2 +- ...PixelSuppressionByDirectionImageFilter.txx | 136 ++++++++++-------- 2 files changed, 74 insertions(+), 64 deletions(-) diff --git a/Code/FeatureExtraction/otbLocalHoughFilter.txx b/Code/FeatureExtraction/otbLocalHoughFilter.txx index c236cbc44b..f676eedd61 100755 --- a/Code/FeatureExtraction/otbLocalHoughFilter.txx +++ b/Code/FeatureExtraction/otbLocalHoughFilter.txx @@ -231,7 +231,7 @@ LocalHoughFilter<TInputImage> m_HoughFilter->SetNumberOfLines( m_NumberOfLines ); m_HoughFilter->SetVariance( m_Variance ); m_HoughFilter->SetDiscRadius( m_DiscRadius ); - //m_HoughFilter->SetThreshold( m_Threshold ); + m_HoughFilter->SetThreshold( m_Threshold ); m_HoughFilter->Modified(); diff --git a/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx b/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx index 9e07785c57..57ff8dfa03 100755 --- a/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx +++ b/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx @@ -43,48 +43,48 @@ PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage>::PixelSuppress template <class TInputImage, class TOutputImage> void -PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> -::SetInputImage(const InputImageType *input) +PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> +::SetInputImage(const InputImageType *input) { this->SetInput(0,input); -} +} template <class TInputImage, class TOutputImage> void -PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> -::SetInputImageDirection(const InputImageType *input) +PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> +::SetInputImageDirection(const InputImageType *input) { this->SetInput(1,input); } -template <class TInputImage, class TOutputImage> +template <class TInputImage, class TOutputImage> const -typename PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage>::InputImageType * -PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> -::GetInputImage(void) -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - - return static_cast<const TInputImage * > - (this->GetInput(0) ); -} - -template <class TInputImage, class TOutputImage> +typename PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage>::InputImageType * +PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> +::GetInputImage(void) +{ + if (this->GetNumberOfInputs() < 1) + { + return 0; + } + + return static_cast<const TInputImage * > + (this->GetInput(0) ); +} + +template <class TInputImage, class TOutputImage> const -typename PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage>::InputImageType * -PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> -::GetInputImageDirection(void) -{ - if (this->GetNumberOfInputs() < 1) - { - return 0; - } - - return static_cast<const TInputImage * > - (this->GetInput(1) ); +typename PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage>::InputImageType * +PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage> +::GetInputImageDirection(void) +{ + if (this->GetNumberOfInputs() < 1) + { + return 0; + } + + return static_cast<const TInputImage * > + (this->GetInput(1) ); } template <class TInputImage, class TOutputImage> @@ -244,49 +244,59 @@ void PixelSuppressionByDirectionImageFilter< TInputImage, TOutputImage>::Threade continue; // Distance between pixel (x,y) and central pixel - DistanceXY = static_cast<double>(sqrt(x*x+y*y)); +// DistanceXY = static_cast<double>(sqrt(x*x+y*y)); // If the pixel (x,y) is inside the circle of radius m_Radius - if ( DistanceXY <= m_Radius[0] ) - { +// if ( DistanceXY <= m_Radius[0] ) +// { - // Rotation of the system axis in the direction of the central pixel (thetaXcYc) - // (x,y) -> (xt,yt) - TRANSITION_MATRIX( x, y, ThetaXcYc, xt, yt ); +// // Rotation of the system axis in the direction of the central pixel (thetaXcYc) +// // (x,y) -> (xt,yt) +// TRANSITION_MATRIX( x, y, ThetaXcYc, xt, yt ); + - // The absolute value of yt/xt is used to bring back the pixel (xt,yt) - // in positive co-ordinates - // => thetaxtyt is included in the interval [0;PI/2] - if ( xt != 0. ) - Thetaxtyt = atan( fabs(yt/xt) ); - else - Thetaxtyt = M_PI/2.; - +// // The absolute value of yt/xt is used to bring back the pixel (xt,yt) +// // in positive co-ordinates +// // => thetaxtyt is included in the interval [0;PI/2] +// if ( xt != 0. ) +// Thetaxtyt = atan( fabs(yt/xt) ); +// else +// Thetaxtyt = M_PI/2.; + - // Then, we test if the pixel is included in the interval [0;m_AngularBeam] - if ( (0. <= Thetaxtyt) and - (Thetaxtyt <= m_AngularBeam) ) - { - // The pixel is located in the direction of the central pixel - // Get the direction of the pixel (X,Y) in the image of diretions - ThetaXY = static_cast<double>(bit.GetPixel(i)); +// // Then, we test if the pixel is included in the interval [0;m_AngularBeam] +// if ( (0. <= Thetaxtyt) and +// (Thetaxtyt <= m_AngularBeam) ) +// { +// // The pixel is located in the direction of the central pixel +// // Get the direction of the pixel (X,Y) in the image of diretions +// ThetaXY = static_cast<double>(bit.GetPixel(i)); - // Angular tolerance on the direction of the central pixel - MinThetaXcYc = ThetaXcYc - m_AngularBeam; - MaxThetaXcYc = ThetaXcYc + m_AngularBeam; +// // Angular tolerance on the direction of the central pixel +// MinThetaXcYc = ThetaXcYc - m_AngularBeam; +// MaxThetaXcYc = ThetaXcYc + m_AngularBeam; - // Test if the pixel belongs to a line - if ( (MinThetaXcYc <= ThetaXY) and - (ThetaXY <= MaxThetaXcYc ) ) +// // Test if the pixel belongs to a line +// if ( (MinThetaXcYc <= ThetaXY) && +// (ThetaXY <= MaxThetaXcYc ) ) - IsLine = true; - - } +// IsLine = true; +// } + + Thetaxtyt = atan2(y,x) - M_PI/2.0; + if(Thetaxtyt < 0) + Thetaxtyt = M_PI + Thetaxtyt; + +// std::cout << sin(Thetaxtyt) << " " << sin(ThetaXcYc) << " " << sin(bit.GetPixel(i)) << std::endl; + if( (fabs(sin(Thetaxtyt-ThetaXcYc)) <= sin(m_AngularBeam)) && (fabs(sin(bit.GetPixel(i)-ThetaXcYc)) <= sin(m_AngularBeam)) ) + IsLine = true; +// } + - } + } - } // end of the loop on the pixels of the region + // end of the loop on the pixels of the region // Assignment of this value to the output pixel -- GitLab