diff --git a/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.h b/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.h index e61b195d869777b8e76de3313fef9672b10b0a5b..0f3262166ed80bc3a7249e0a4d37cfc99a3da6b5 100755 --- a/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.h +++ b/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.h @@ -8,8 +8,8 @@ $Id$ =========================================================================*/ -#ifndef __otbAssymetricFusionOfLineDetectorImageFilter_h -#define __otbAssymetricFusionOfLineDetectorImageFilter_h +#ifndef __otbAssymmetricFusionOfLineDetectorImageFilter_h +#define __otbAssymmetricFusionOfLineDetectorImageFilter_h #include "itkImageToImageFilter.h" @@ -21,14 +21,14 @@ namespace otb { -/** \class AssymetricFusionOfLineDtectorImageFilter +/** \class AssymmetricFusionOfLineDetectorImageFilter * */ template <class TInputImage, class TOutputImage, class InterpolatorType = itk::BSplineInterpolateImageFunction<TInputImage> > -class AssymetricFusionOfLineDetectorImageFilter : public itk::ImageToImageFilter< TInputImage, TOutputImage > +class AssymmetricFusionOfLineDetectorImageFilter : public itk::ImageToImageFilter< TInputImage, TOutputImage > { public: @@ -46,14 +46,14 @@ public: typedef TOutputImage InputImageType2; - typedef AssymetricFusionOfLineDetectorImageFilter Self; + typedef AssymmetricFusionOfLineDetectorImageFilter Self; typedef itk::ImageToImageFilter< InputImageType, OutputImageType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; itkNewMacro(Self); - itkTypeMacro(AssymetricFusionOfLineDetectorImageFilter, ImageToImageFilter); + itkTypeMacro(AssymmetricFusionOfLineDetectorImageFilter, ImageToImageFilter); typedef typename InputImageType::PixelType InputPixelType; typedef typename InputImageType::SizeType SizeType; @@ -76,8 +76,8 @@ public: itkGetConstReferenceMacro(WidthLine, unsigned int); protected: - AssymetricFusionOfLineDetectorImageFilter(); - virtual ~AssymetricFusionOfLineDetectorImageFilter() {}; + AssymmetricFusionOfLineDetectorImageFilter(); + virtual ~AssymmetricFusionOfLineDetectorImageFilter() {}; typedef otb::LineRatioDetector< InputImageType, OutputImageType, InterpolatorType > LineRatioType; typedef otb::LineCorrelationDetector< InputImageType, OutputImageType, InterpolatorType > LineCorrelationType; @@ -88,7 +88,7 @@ protected: void PrintSelf(std::ostream& os, itk::Indent indent) const; private: - AssymetricFusionOfLineDetectorImageFilter(const Self&); //purposely not implemented + AssymmetricFusionOfLineDetectorImageFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented /** Length of the linear feature = 2*m_LengthLine+1 */ @@ -104,7 +104,7 @@ private: } // end namespace otb #ifndef OTB_MANUAL_INSTANTIATION -#include "otbAssymetricFusionOfLineDetectorImageFilter.txx" +#include "otbAssymmetricFusionOfLineDetectorImageFilter.txx" #endif diff --git a/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.txx b/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.txx index 51dcc1aa3837b398ee65b670ab96ea7546e855e1..f44e829c2a3ed109b917787c41519cf19ea2aedb 100755 --- a/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.txx +++ b/Code/FeatureExtraction/otbAssymetricFusionOfLineDetectorImageFilter.txx @@ -8,10 +8,10 @@ $Id$ =========================================================================*/ -#ifndef __otbAssymetricFusionOfLineDetectorImageFilter_txx -#define __otbAssymetricFusionOfLineDetectorImageFilter_txx +#ifndef __otbAssymmetricFusionOfLineDetectorImageFilter_txx +#define __otbAssymmetricFusionOfLineDetectorImageFilter_txx -#include "otbAssymetricFusionOfLineDetectorImageFilter.h" +#include "otbAssymmetricFusionOfLineDetectorImageFilter.h" namespace otb @@ -21,8 +21,8 @@ namespace otb * */ template <class TInputImage, class TOutputImage, class InterpolatorType> -AssymetricFusionOfLineDetectorImageFilter<TInputImage, TOutputImage, InterpolatorType> -::AssymetricFusionOfLineDetectorImageFilter() +AssymmetricFusionOfLineDetectorImageFilter<TInputImage, TOutputImage, InterpolatorType> +::AssymmetricFusionOfLineDetectorImageFilter() { m_LengthLine = 1; m_WidthLine = 0; @@ -35,7 +35,7 @@ AssymetricFusionOfLineDetectorImageFilter<TInputImage, TOutputImage, Interpolato template <class TInputImage, class TOutputImage, class InterpolatorType> void -AssymetricFusionOfLineDetectorImageFilter<TInputImage, TOutputImage, InterpolatorType> +AssymmetricFusionOfLineDetectorImageFilter<TInputImage, TOutputImage, InterpolatorType> ::GenerateData() { m_LineRatio->SetInput( this->GetInput() ); @@ -60,7 +60,7 @@ AssymetricFusionOfLineDetectorImageFilter<TInputImage, TOutputImage, Interpolato */ template <class TInputImage, class TOutput, class InterpolatorType> void -AssymetricFusionOfLineDetectorImageFilter<TInputImage, TOutput, InterpolatorType> +AssymmetricFusionOfLineDetectorImageFilter<TInputImage, TOutput, InterpolatorType> ::PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf( os, indent ); diff --git a/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.h b/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.h index 5bb39ef919da44d2ac77149ded6b4c58fb4ec6c9..6b0262f998161d4d6d2b4b7bed15118ad042e1ca 100755 --- a/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.h +++ b/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.h @@ -98,6 +98,8 @@ private: SizeType m_Radius; InputRealType m_AngularBeam; + double m_Distance; + }; } // end namespace otb diff --git a/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx b/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx index d9542cdb5b1589578c426b8777f4d5d2ca6378f2..b5195b5028909591fb23a9cfa7cd88b429c223b4 100755 --- a/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx +++ b/Code/FeatureExtraction/otbPixelSuppressionByDirectionImageFilter.txx @@ -35,6 +35,7 @@ PixelSuppressionByDirectionImageFilter<TInputImage, TOutputImage>::PixelSuppress { m_Radius.Fill(1); m_AngularBeam = static_cast<InputRealType>(0.); + m_Distance = sqrt(2.); } template <class TInputImage, class TOutputImage> @@ -168,9 +169,32 @@ void PixelSuppressionByDirectionImageFilter< TInputImage, TOutputImage>::Threade typename TInputImage::IndexType bitIndex; + //--------------------------------------------------------------------------- + + InputPixelType PixelValue; + + // location of the pixel central in the input image + int Xc, Yc; + + // Pixel location in the system axis of the region + int x, y; + + // Distance between pixel (x,y) and the pixel central of the region + double DistanceXY; + + double tanXY; + double MintanXcYc, MaxtanXcYc; + + // Pixel Direction + double DirectionXcYc, DirectionXY; + //--------------------------------------------------------------------------- + // Distance max between two pixels neighbours + m_Distance = static_cast<double>(m_Radius[0]*sqrt(2.)); + + // Process each of the boundary faces. These are N-d regions which border // the edge of the buffer. for (fit=faceList.begin(); fit != faceList.end(); ++fit) @@ -183,31 +207,58 @@ void PixelSuppressionByDirectionImageFilter< TInputImage, TOutputImage>::Threade bit.OverrideBoundaryCondition(&cbc); bit.GoToBegin(); - - // --------------------------------------------------------------------------- - - InputPixelType PixelValue; - - // --------------------------------------------------------------------------- - - + + while ( ! bit.IsAtEnd() ) { - - + + // Location of the pixel central of the region + bitIndex = bit.GetIndex(); + + Xc = bitIndex[0]; + Yc = bitIndex[1]; + + DirectionXcYc = static_cast<double>( bit.GetCenterPixel() ); + + MintanXcYc = tan( DirectionXcYc - m_AngularBeam ); + MaxtanXcYc = tan( DirectionXcYc + m_AngularBeam ); + + PixelValue = itin.Get(); + // Loop on the region for (i = 0; i < neighborhoodSize; ++i) { - + // Pixel location in the system axis of the region + bitIndex = bit.GetIndex(i); + + x = bitIndex[0] - Xc; + y = bitIndex[1] - Yc; + + // Distance between pixel (x,y) and pixel central + DistanceXY = static_cast<double>(sqrt(x*x+y*y)); + + // If the pixel (x,y) is inside the circle of radius m_Distance + if ( DistanceXY < m_Distance ) + { + tanXY = static_cast<double>(y/x); + + if ( (MintanXcYc <= tanXY) and + (tanXY <= MaxtanXcYc) ) + { + DirectionXY = static_cast<double>(bit.GetPixel(i)); + + if ( ((DirectionXcYc - m_AngularBeam) <= DirectionXY) and + (DirectionXY <= (DirectionXcYc + m_AngularBeam)) ) + + // Assignment of this value to the output pixel + itout.Set( static_cast<OutputPixelType>(PixelValue) ); + + } + } } // end of the loop on the pixels of the region - - - - // Assignment of this value to the output pixel - itout.Set( static_cast<OutputPixelType>(PixelValue) ); - + ++bit; ++itin; ++itout;