From 7bd2e1c677a54144a6f9ef16582d076eef0e53d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Fri, 27 Feb 2009 09:44:52 +0800 Subject: [PATCH] STYLE: with astyle --- .../otbBinaryImageDensityFunction.h | 44 +- .../otbBinaryImageDensityFunction.txx | 70 +- .../otbBinaryImageToDensityImageFilter.txx | 28 +- Code/BasicFilters/otbEdgeDensityImageFilter.h | 20 +- .../otbEdgeDensityImageFilter.txx | 10 +- .../otbEstimateInnerProductPCAImageFilter.h | 2 +- .../otbEstimateInnerProductPCAImageFilter.txx | 6 +- ...otbFunctionWithNeighborhoodToImageFilter.h | 24 +- ...bFunctionWithNeighborhoodToImageFilter.txx | 26 +- .../otbInnerProductPCAImageFilter.h | 18 +- .../otbInnerProductPCAImageFilter.txx | 2 +- ...pleToVariableDimensionHistogramGenerator.h | 65 +- ...eToVariableDimensionHistogramGenerator.txx | 120 +-- .../otbNormalizeInnerProductPCAImageFilter.h | 2 +- ...otbNormalizeInnerProductPCAImageFilter.txx | 10 +- ...StreamingInnerProductVectorImageFilter.txx | 122 +-- .../otbUnaryFunctorObjectListBooleanFilter.h | 2 +- ...otbUnaryFunctorObjectListBooleanFilter.txx | 12 +- .../otbUnaryFunctorObjectListFilter.h | 2 +- Code/Common/otbDrawLineSpatialObjectFilter.h | 14 +- .../Common/otbDrawLineSpatialObjectFilter.txx | 8 +- .../otbDrawLineSpatialObjectListFilter.h | 22 +- .../otbDrawLineSpatialObjectListFilter.txx | 200 ++--- ...otbLineSpatialObjectListToPointSetFilter.h | 6 +- .../otbPolyLineParametricPathWithValue.h | 18 +- .../otbPolyLineParametricPathWithValue.txx | 4 +- Code/Common/otbPolygon.txx | 6 +- ...nctorNeighborhoodWithOffsetImageFilter.txx | 2 +- Code/Common/otbVectorDataExtractROI.h | 18 +- Code/Common/otbVectorDataExtractROI.txx | 22 +- .../otbAngularSecondMomentumTextureFunctor.h | 24 +- .../otbClusterProminenceTextureFunctor.h | 20 +- .../otbClusterShadeTextureFunctor.h | 18 +- .../otbContrastTextureFunctor.h | 36 +- .../otbCorrelationTextureFunctor.h | 48 +- .../otbDifferenceEntropyTextureFunctor.h | 38 +- .../otbDifferenceVarianceTextureFunctor.h | 58 +- .../otbEnergyTextureFunctor.h | 28 +- .../otbEntropyTextureFunctor.h | 30 +- .../otbExtractSegmentsImageFilter.txx | 2 +- ...ationMeasureOfCorrelation1TextureFunctor.h | 60 +- ...ationMeasureOfCorrelation2TextureFunctor.h | 48 +- ...otbInverseDifferenceMomentTextureFunctor.h | 34 +- .../otbLineSegmentDetector.h | 134 ++-- .../otbLineSegmentDetector.txx | 683 ++++++++--------- ...tialObjectListToRightAnglePointSetFilter.h | 20 +- ...alObjectListToRightAnglePointSetFilter.txx | 224 +++--- .../FeatureExtraction/otbMeanTextureFunctor.h | 24 +- .../otbPanTexTextureFunctor.h | 82 +- .../otbPanTexTextureImageFilter.h | 14 +- .../otbPanTexTextureImageFilter.txx | 5 +- .../otbPanTexTextureImageFunctionFilter.h | 14 +- .../FeatureExtraction/otbSFSTexturesFunctor.h | 472 ++++++------ .../otbSFSTexturesImageFilter.h | 132 ++-- .../otbSFSTexturesImageFilter.txx | 82 +- .../otbSumAverageTextureFunctor.h | 70 +- .../otbSumEntropyTextureFunctor.h | 58 +- .../otbSumVarianceTextureFunctor.h | 52 +- .../FeatureExtraction/otbTextureFunctorBase.h | 425 ++++++----- .../otbTextureImageFunction.h | 10 +- .../otbTextureImageFunction.txx | 2 +- .../otbVarianceTextureFunctor.h | 18 +- Code/IO/otbImageSeriesFileReader.h | 705 +++++++++--------- Code/IO/otbImageSeriesFileReader.txx | 121 +-- Code/IO/otbImageSeriesFileReaderBase.h | 245 +++--- Code/IO/otbImageSeriesFileReaderBase.txx | 186 ++--- Code/Learning/otbSVMClassifier.txx | 6 +- Code/MultiScale/otbHaarOperator.h | 79 +- Code/MultiScale/otbStationaryFilterBank.h | 57 +- Code/MultiScale/otbStationaryFilterBank.txx | 41 +- Code/MultiScale/otbWPCost.h | 25 +- Code/MultiScale/otbWaveletForwardTransform.h | 27 +- .../MultiScale/otbWaveletForwardTransform.txx | 15 +- Code/MultiScale/otbWaveletOperator.h | 39 +- .../otbWaveletPacketForwardTransform.h | 29 +- .../otbWaveletPacketForwardTransform.txx | 13 +- Code/MultiScale/otb_9_7_Operator.h | 87 +-- Code/Projections/otbGeocentricTransform.h | 74 +- Code/Projections/otbGeocentricTransform.txx | 76 +- Code/Radiometry/otbBuiltUpIndicesFunctor.h | 8 +- .../otbMultiChannelGAndRIndexImageFilter.h | 16 +- ...bMultiChannelRAndBAndNIRIndexImageFilter.h | 18 +- ...nelRAndBAndNIRVegetationIndexImageFilter.h | 18 +- ...bMultiChannelRAndGAndNIRIndexImageFilter.h | 18 +- ...nelRAndGAndNIRVegetationIndexImageFilter.h | 18 +- .../otbMultiChannelRAndNIRIndexImageFilter.h | 16 +- ...ChannelRAndNIRVegetationIndexImageFilter.h | 16 +- Code/Radiometry/otbSoilIndicesFunctor.h | 8 +- Code/Radiometry/otbVegetationIndicesFunctor.h | 64 +- Code/Radiometry/otbWaterIndicesFunctor.h | 12 +- .../otbPolygonListToRCC8GraphFilter.txx | 24 +- Code/Visu/otbImageViewerBase.txx | 22 +- Code/Visu/otbImageWidgetBase.txx | 20 +- Code/VisuRefac/otbBlendingFunction.h | 4 +- Code/VisuRefac/otbBlendingImageFilter.h | 30 +- .../otbChangeExtractRegionActionHandler.h | 50 +- ...tbChangeScaledExtractRegionActionHandler.h | 50 +- Code/VisuRefac/otbImageLayer.h | 88 +-- Code/VisuRefac/otbImageLayer.txx | 112 +-- Code/VisuRefac/otbImageLayerGenerator.h | 22 +- Code/VisuRefac/otbImageLayerGenerator.txx | 54 +- Code/VisuRefac/otbImageView.h | 20 +- Code/VisuRefac/otbImageView.txx | 62 +- Code/VisuRefac/otbImageViewerModel.h | 32 +- Code/VisuRefac/otbImageViewerModel.txx | 228 +++--- Code/VisuRefac/otbImageWidget.h | 10 +- Code/VisuRefac/otbImageWidget.txx | 168 ++--- Code/VisuRefac/otbImageWidgetActionHandler.h | 30 +- Code/VisuRefac/otbImageWidgetController.cxx | 34 +- Code/VisuRefac/otbImageWidgetController.h | 22 +- Code/VisuRefac/otbLayer.h | 24 +- Code/VisuRefac/otbMultiplyBlendingFunction.h | 96 +-- Code/VisuRefac/otbRenderingFunction.h | 26 +- Code/VisuRefac/otbRenderingImageFilter.h | 20 +- Code/VisuRefac/otbStandardRenderingFunction.h | 84 +-- .../otbUniformAlphaBlendingFunction.h | 6 +- .../otbWidgetResizingActionHandler.h | 104 +-- .../Utilities/vxl/vcl/tests/CMakeLists.txt | 2 + .../Utilities/vxl/vcl/tests/test_clean.cxx | 10 + .../Utilities/vxl/vcl/tests/test_driver.cxx | 5 +- 120 files changed, 3747 insertions(+), 3619 deletions(-) mode change 100755 => 100644 Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.h mode change 100755 => 100644 Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.txx mode change 100755 => 100644 Code/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbClusterProminenceTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbClusterShadeTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbContrastTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbCorrelationTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbDifferenceEntropyTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbDifferenceVarianceTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbEnergyTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbEntropyTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbInformationMeasureOfCorrelation1TextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbInformationMeasureOfCorrelation2TextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbInverseDifferenceMomentTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbMeanTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbSumAverageTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbSumEntropyTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbSumVarianceTextureFunctor.h mode change 100755 => 100644 Code/FeatureExtraction/otbTextureFunctorBase.h mode change 100755 => 100644 Code/FeatureExtraction/otbVarianceTextureFunctor.h create mode 100644 Utilities/ITK/Utilities/vxl/vcl/tests/test_clean.cxx diff --git a/Code/BasicFilters/otbBinaryImageDensityFunction.h b/Code/BasicFilters/otbBinaryImageDensityFunction.h index bff63bbaa8..0cf8e28700 100644 --- a/Code/BasicFilters/otbBinaryImageDensityFunction.h +++ b/Code/BasicFilters/otbBinaryImageDensityFunction.h @@ -36,23 +36,23 @@ namespace otb * If called with a ContinuousIndex or Point, the calculation is performed * at the nearest neighbor. * - * This class is templated over the input image type and the + * This class is templated over the input image type and the * coordinate representation type (e.g. float or double ). * * \ingroup ImageFunctions */ template <class TInputImage, class TCoordRep = float > class ITK_EXPORT BinaryImageDensityFunction : - public itk::ImageFunction< TInputImage, typename itk::NumericTraits<typename TInputImage::PixelType>::RealType,TCoordRep > + public itk::ImageFunction< TInputImage, typename itk::NumericTraits<typename TInputImage::PixelType>::RealType,TCoordRep > { public: /** Standard class typedefs. */ typedef BinaryImageDensityFunction Self; typedef itk::ImageFunction<TInputImage,typename itk::NumericTraits<typename TInputImage::PixelType>::RealType, - TCoordRep > Superclass; + TCoordRep > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Run-time type information (and related methods). */ itkTypeMacro(BinaryImageDensityFunction, itk::ImageFunction); @@ -67,7 +67,7 @@ public: /** Index typedef support. */ typedef typename Superclass::IndexType IndexType; - + /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; @@ -75,40 +75,40 @@ public: typedef typename Superclass::PointType PointType; /** Dimension of the underlying image. */ -itkStaticConstMacro(ImageDimension, unsigned int, - InputImageType::ImageDimension); + itkStaticConstMacro(ImageDimension, unsigned int, + InputImageType::ImageDimension); /** Datatype used for the density */ typedef typename itk::NumericTraits<typename InputImageType::PixelType>::RealType - RealType; + RealType; /** Evalulate the function at specified index */ virtual RealType EvaluateAtIndex( const IndexType& index ) const; - + /** Evaluate the function at non-integer positions */ virtual RealType Evaluate( const PointType& point ) const - { - IndexType index; - this->ConvertPointToNearestIndex( point, index ); - return this->EvaluateAtIndex( index ); - } - virtual RealType EvaluateAtContinuousIndex( + { + IndexType index; + this->ConvertPointToNearestIndex( point, index ); + return this->EvaluateAtIndex( index ); + } + virtual RealType EvaluateAtContinuousIndex( const ContinuousIndexType& cindex ) const - { - IndexType index; - this->ConvertContinuousIndexToNearestIndex( cindex, index ); - return this->EvaluateAtIndex( index ) ; - } + { + IndexType index; + this->ConvertContinuousIndexToNearestIndex( cindex, index ); + return this->EvaluateAtIndex( index ) ; + } /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ itkSetMacro( NeighborhoodRadius, unsigned int ); itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int ); - + protected: BinaryImageDensityFunction(); - ~BinaryImageDensityFunction(){}; + ~BinaryImageDensityFunction() {}; void PrintSelf(std::ostream& os, itk::Indent indent) const; private: diff --git a/Code/BasicFilters/otbBinaryImageDensityFunction.txx b/Code/BasicFilters/otbBinaryImageDensityFunction.txx index faabc4abc3..7ea47dbdea 100644 --- a/Code/BasicFilters/otbBinaryImageDensityFunction.txx +++ b/Code/BasicFilters/otbBinaryImageDensityFunction.txx @@ -61,43 +61,43 @@ typename BinaryImageDensityFunction<TInputImage,TCoordRep> BinaryImageDensityFunction<TInputImage,TCoordRep> ::EvaluateAtIndex(const IndexType& index) const { - RealType sum; - RealType var; - - sum = itk::NumericTraits<RealType>::Zero; - - if( !this->GetInputImage() ) - { - return ( itk::NumericTraits<RealType>::max() ); - } - - if ( !this->IsInsideBuffer( index ) ) - { - return ( itk::NumericTraits<RealType>::max() ); - } + RealType sum; + RealType var; + + sum = itk::NumericTraits<RealType>::Zero; + + if ( !this->GetInputImage() ) + { + return ( itk::NumericTraits<RealType>::max() ); + } + + if ( !this->IsInsideBuffer( index ) ) + { + return ( itk::NumericTraits<RealType>::max() ); + } // Create an N-d neighborhood kernel, using a zeroflux boundary condition - typename InputImageType::SizeType kernelSize; - kernelSize.Fill( m_NeighborhoodRadius ); - - itk::ConstNeighborhoodIterator<InputImageType> - it(kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion()); - - // Set the iterator at the desired location - it.SetLocation(index); - - // Walk the neighborhood - const unsigned int size = it.Size(); - for (unsigned int i = 0; i < size; ++i) - { - const RealType value = static_cast<RealType>( it.GetPixel(i) ); - sum += value; - } - - const RealType num = static_cast<RealType>( size ); - var = sum/num ; - - return var ; + typename InputImageType::SizeType kernelSize; + kernelSize.Fill( m_NeighborhoodRadius ); + + itk::ConstNeighborhoodIterator<InputImageType> + it(kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion()); + + // Set the iterator at the desired location + it.SetLocation(index); + + // Walk the neighborhood + const unsigned int size = it.Size(); + for (unsigned int i = 0; i < size; ++i) + { + const RealType value = static_cast<RealType>( it.GetPixel(i) ); + sum += value; + } + + const RealType num = static_cast<RealType>( size ); + var = sum/num ; + + return var ; } diff --git a/Code/BasicFilters/otbBinaryImageToDensityImageFilter.txx b/Code/BasicFilters/otbBinaryImageToDensityImageFilter.txx index 2a95dd2579..02d191ebfd 100644 --- a/Code/BasicFilters/otbBinaryImageToDensityImageFilter.txx +++ b/Code/BasicFilters/otbBinaryImageToDensityImageFilter.txx @@ -48,7 +48,7 @@ void BinaryImageToDensityImageFilter<TInputImage, TOutputImage, TCountFunction> ::ThreadedGenerateData( const InputImageRegionType &outputRegionForThread, int threadId ) { - + InputImagePointerType input = const_cast<InputImageType * > (this->GetInput()); OutputImagePointerType output = this->GetOutput(); @@ -56,23 +56,23 @@ BinaryImageToDensityImageFilter<TInputImage, TOutputImage, TCountFunction> itk::ImageRegionConstIterator<InputImageType> it(input,outputRegionForThread ); itk::ImageRegionIterator<OutputImageType> itOut(output,outputRegionForThread ); - + it.GoToBegin(); itOut.GoToBegin(); - - while(!it.IsAtEnd()) + + while (!it.IsAtEnd()) + { + m_CountFunction->SetNeighborhoodRadius(m_NeighborhoodRadius); + typename InputImageType::IndexType index = it.GetIndex(); + + if (outputRegionForThread.IsInside(index)) { - m_CountFunction->SetNeighborhoodRadius(m_NeighborhoodRadius); - typename InputImageType::IndexType index = it.GetIndex(); - - if(outputRegionForThread.IsInside(index)) - { - itOut.Set(m_CountFunction->EvaluateAtIndex(index)); - } - - ++itOut; - ++it; + itOut.Set(m_CountFunction->EvaluateAtIndex(index)); } + + ++itOut; + ++it; + } } /** PrintSelf method */ diff --git a/Code/BasicFilters/otbEdgeDensityImageFilter.h b/Code/BasicFilters/otbEdgeDensityImageFilter.h index e2d6f6ee27..81cdd4d44c 100644 --- a/Code/BasicFilters/otbEdgeDensityImageFilter.h +++ b/Code/BasicFilters/otbEdgeDensityImageFilter.h @@ -29,10 +29,10 @@ PURPOSE. See the above copyright notices for more information. /** \class EdgeDensityImageFilter - * \brief This composite filter computes the density of the edges around a pixel. - * - * - */ + * \brief This composite filter computes the density of the edges around a pixel. + * + * + */ namespace otb { @@ -71,15 +71,15 @@ public: /** Count Density Function typedef support*/ typedef TDensityCount DensityCountFunctionType; - + /** PointSetToDensityImageFilter support*/ - typedef otb::BinaryImageToDensityImageFilter<InputImageType, - OutputImageType, - DensityCountFunctionType> DensityImageType; - + typedef otb::BinaryImageToDensityImageFilter<InputImageType, + OutputImageType, + DensityCountFunctionType> DensityImageType; + typedef typename DensityImageType::Pointer DensityImagePointerType; - + /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ itkSetMacro( NeighborhoodRadius, unsigned int ); diff --git a/Code/BasicFilters/otbEdgeDensityImageFilter.txx b/Code/BasicFilters/otbEdgeDensityImageFilter.txx index 806cad874a..a111f01147 100644 --- a/Code/BasicFilters/otbEdgeDensityImageFilter.txx +++ b/Code/BasicFilters/otbEdgeDensityImageFilter.txx @@ -31,7 +31,7 @@ EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> ::EdgeDensityImageFilter() { this->SetNumberOfRequiredInputs( 1 ); - + m_NeighborhoodRadius = 1; m_Detector = DetectorType::New(); m_DensityImageFilter = DensityImageType::New(); @@ -66,7 +66,7 @@ EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> /** Apply Canny Detector*/ m_Detector->SetInput(ptr); - + /** Compute density on the binaruzed Image */ m_DensityImageFilter->SetInput(m_Detector->GetOutput()); @@ -95,9 +95,9 @@ EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> * Get Detector */ template <class TInputImage , class TOutputImage, class TEdgeDetector, class TDensityCount> -typename EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> +typename EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> ::DetectorType * -EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> +EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> ::GetDetector() { return m_Detector; @@ -110,7 +110,7 @@ EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> -----------------------------------------------------------------*/ template <class TInputImage , class TOutputImage, class TEdgeDetector, class TDensityCount> void -EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> +EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount> ::PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); diff --git a/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.h b/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.h index 2bc5a7ac14..fa88fca89f 100644 --- a/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.h +++ b/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.h @@ -92,7 +92,7 @@ private: // The number of output Pricipal Components unsigned int m_NumberOfPrincipalComponentsRequired; - /** Inner Product Matrix pre computed */ + /** Inner Product Matrix pre computed */ MatrixType m_InnerProduct; /** Contains Eigen Vectors Of Inner Product Matrix computed */ diff --git a/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.txx b/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.txx index 59e29daf4a..b4c64e0b73 100644 --- a/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.txx +++ b/Code/BasicFilters/otbEstimateInnerProductPCAImageFilter.txx @@ -54,7 +54,7 @@ template<class TInputImage, class TOutputImage> void EstimateInnerProductPCAImageFilter<TInputImage,TOutputImage> ::GenerateOutputInformation(void) -{ +{ Superclass::GenerateOutputInformation(); this->GetOutput()->SetNumberOfComponentsPerPixel(m_NumberOfPrincipalComponentsRequired); } @@ -112,10 +112,10 @@ EstimateInnerProductPCAImageFilter<TInputImage,TOutputImage> outputPixel.SetSize(m_NumberOfPrincipalComponentsRequired); outputPixel.Fill(0); - for(unsigned int img_number = 0; img_number < numberOfTrainingImages; img_number++ ) + for (unsigned int img_number = 0; img_number < numberOfTrainingImages; img_number++ ) { unsigned int indexNumberOfTrainingImages = numberOfTrainingImages-1; - for( unsigned int vec_number = 0 ; vec_number < m_NumberOfPrincipalComponentsRequired; vec_number++, indexNumberOfTrainingImages-- ) + for ( unsigned int vec_number = 0 ; vec_number < m_NumberOfPrincipalComponentsRequired; vec_number++, indexNumberOfTrainingImages-- ) { outputPixel[vec_number] += static_cast<OutputInternalPixelType>( static_cast<double>(inputPixel[img_number]) * static_cast<double>(m_EigenVectorsOfInnerProductMatrix[img_number][indexNumberOfTrainingImages])); } diff --git a/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.h b/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.h index f434178a4c..8647dab668 100644 --- a/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.h +++ b/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.h @@ -51,7 +51,7 @@ namespace otb template <class TInputImage, class TOutputImage,class TFunction> class ITK_EXPORT FunctionWithNeighborhoodToImageFilter : -public itk::InPlaceImageFilter<TInputImage,TOutputImage> + public itk::InPlaceImageFilter<TInputImage,TOutputImage> { public: /** Standard class typedefs. */ @@ -96,22 +96,22 @@ public: /** Accessors */ itkGetMacro(Radius, InputImageSizeType); void SetRadius( InputImageSizeType & rad ) - { - m_Radius = rad; - m_Function->SetRadius( rad ); - this->Modified(); - } + { + m_Radius = rad; + m_Function->SetRadius( rad ); + this->Modified(); + } itkGetMacro(Offset, InputImageOffsetType); void SetOffset( InputImageOffsetType & offset ) - { - m_Offset = offset; - m_Function->SetOffset( offset ); - this->Modified(); - } + { + m_Offset = offset; + m_Function->SetOffset( offset ); + this->Modified(); + } protected: FunctionWithNeighborhoodToImageFilter(); - virtual ~FunctionWithNeighborhoodToImageFilter(){}; + virtual ~FunctionWithNeighborhoodToImageFilter() {}; void BeforeThreadedGenerateData(); diff --git a/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.txx b/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.txx index b07cff621b..89b457c0b4 100644 --- a/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.txx +++ b/Code/BasicFilters/otbFunctionWithNeighborhoodToImageFilter.txx @@ -48,7 +48,7 @@ template <class TInputImage, class TOutputImage, class TFunction > void FunctionWithNeighborhoodToImageFilter<TInputImage,TOutputImage,TFunction> ::BeforeThreadedGenerateData() -{ +{ Superclass::BeforeThreadedGenerateData(); InputImageConstPointer inputPtr = dynamic_cast<const TInputImage*>((itk::ProcessObject::GetInput(0))); @@ -59,11 +59,11 @@ FunctionWithNeighborhoodToImageFilter<TInputImage,TOutputImage,TFunction> } m_Function->SetInputImage(inputPtr); - for(unsigned int i = 0 ; i<static_cast<unsigned int>(this->GetNumberOfThreads()); i++) - { - FunctionPointerType func = m_Function; - m_FunctionList.push_back( func ); - } + for (unsigned int i = 0 ; i<static_cast<unsigned int>(this->GetNumberOfThreads()); i++) + { + FunctionPointerType func = m_Function; + m_FunctionList.push_back( func ); + } } template <class TInputImage, class TOutputImage, class TFunction > @@ -142,13 +142,13 @@ FunctionWithNeighborhoodToImageFilter<TInputImage,TOutputImage,TFunction> outputIt.GoToBegin(); while ( !inputIt.IsAtEnd() ) - { - outputIt.Set( static_cast<OutputImagePixelType>(m_FunctionList[threadId]->EvaluateAtIndex(inputIt.GetIndex())) ); - ++inputIt; - ++outputIt; - - progress.CompletedPixel(); // potential exception thrown here - } + { + outputIt.Set( static_cast<OutputImagePixelType>(m_FunctionList[threadId]->EvaluateAtIndex(inputIt.GetIndex())) ); + ++inputIt; + ++outputIt; + + progress.CompletedPixel(); // potential exception thrown here + } } } // end namespace otb diff --git a/Code/BasicFilters/otbInnerProductPCAImageFilter.h b/Code/BasicFilters/otbInnerProductPCAImageFilter.h index d941dfb6fe..1d72ae4647 100644 --- a/Code/BasicFilters/otbInnerProductPCAImageFilter.h +++ b/Code/BasicFilters/otbInnerProductPCAImageFilter.h @@ -31,23 +31,23 @@ namespace otb * itk::ImagePCAShapeModelEstimator) (PCA) on a vector image in streaming capabilities. * Alls channels of the input vector image are used for training images * and also the number of desired largest principal components needed. - * The number of channels of the output image are the user specified number of desired + * The number of channels of the output image are the user specified number of desired * largest principal components. * * The algorithm uses the VNL library to perform the eigen analysis. To speed - * the computation of the instead of performing the eigen analysis of the + * the computation of the instead of performing the eigen analysis of the * covariance vector A*A' where A is a matrix with p x t, p = number of * pixels or voxels in each images and t = number of training images, we * calculate the eigen vectors of the inner product matrix A'*A. The resulting - * eigen vectors (E) are then multiplied with the the matrix A to get the - * principal compoenets. The covariance matrix has a dimension of p x p. Since - * number of pixels in any image being typically very high the eigen - * decomposition becomes computationally expensive. The inner product on the - * other hand has the dimension of t x t, where t is typically much smaller + * eigen vectors (E) are then multiplied with the the matrix A to get the + * principal compoenets. The covariance matrix has a dimension of p x p. Since + * number of pixels in any image being typically very high the eigen + * decomposition becomes computationally expensive. The inner product on the + * other hand has the dimension of t x t, where t is typically much smaller * that p. Hence the eigen decomposition (most compute intensive part) is an * orders of magnitude faster. - * - * The Update() function enables the calculation of the various models, creates + * + * The Update() function enables the calculation of the various models, creates * the membership function objects and populates them. * * \sa itk::ImagePCAShapeModelEstimator diff --git a/Code/BasicFilters/otbInnerProductPCAImageFilter.txx b/Code/BasicFilters/otbInnerProductPCAImageFilter.txx index d2593521f9..d2e29bb1de 100644 --- a/Code/BasicFilters/otbInnerProductPCAImageFilter.txx +++ b/Code/BasicFilters/otbInnerProductPCAImageFilter.txx @@ -41,7 +41,7 @@ template<class TInputImage, class TOutputImage> void InnerProductPCAImageFilter<TInputImage,TOutputImage> ::GenerateOutputInformation(void) -{ +{ Superclass::GenerateOutputInformation(); this->GetOutput()->SetNumberOfComponentsPerPixel(m_NumberOfPrincipalComponentsRequired); } diff --git a/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.h b/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.h old mode 100755 new mode 100644 index 1059063700..171ba9afdd --- a/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.h +++ b/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.h @@ -13,8 +13,8 @@ for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -28,7 +28,8 @@ #include "itkDenseFrequencyContainer.h" #include "itkNumericTraits.h" -namespace otb{ +namespace otb +{ /** \class ListSampleToVariableDimensionHistogramGenerator * \brief Generates a VariableDimensionHistogram from a ListSample @@ -36,20 +37,20 @@ namespace otb{ * This class is a fork from itk::ListSampleToHistogramGenerator * adapted to produce VariableDimensionHistogram, whose dimension can * be chosen at runtime. - * + * * Since the MeasurementVectorSize template parameter is no longer * needed, it has been removed. - * + * * For more information, please refer to the * ListSampleToHistogramGenerator class documentation. * * \sa VariableDimensionHistogram, ListSample, ListSampleToHistogramGenerator */ -template< class TListSample, - class THistogramMeasurement, - class TFrequencyContainer = itk::Statistics::DenseFrequencyContainer> +template< class TListSample, +class THistogramMeasurement, +class TFrequencyContainer = itk::Statistics::DenseFrequencyContainer> class ITK_EXPORT ListSampleToVariableDimensionHistogramGenerator : - public itk::Object + public itk::Object { public: /** Standard typedefs */ @@ -57,55 +58,63 @@ public: typedef itk::Object Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Run-time type information (and related methods). */ itkTypeMacro(ListSampleToVariableDimensionHistogramGenerator, Object) ; - + /** Method for creation through the object factory. */ itkNewMacro(Self) ; - /** Type needed for defining the limits of the histogram bins */ - typedef typename itk::NumericTraits< THistogramMeasurement >::RealType - HistogramMeasurementRealType; + /** Type needed for defining the limits of the histogram bins */ + typedef typename itk::NumericTraits< THistogramMeasurement >::RealType + HistogramMeasurementRealType; typedef itk::Statistics::VariableDimensionHistogram< HistogramMeasurementRealType, - TFrequencyContainer > HistogramType ; + TFrequencyContainer > HistogramType ; typedef typename HistogramType::SizeType HistogramSizeType ; typedef typename HistogramType::MeasurementVectorType MeasurementVectorType; /** plug in the ListSample object */ void SetListSample(const TListSample* list) - { - m_List = list ; - } + { + m_List = list ; + } void SetMarginalScale(float scale) - { m_MarginalScale = scale ; } + { + m_MarginalScale = scale ; + } void SetNumberOfBins(HistogramSizeType sizes) - { m_Sizes = sizes ; } + { + m_Sizes = sizes ; + } HistogramType* GetOutput() const - { return m_Histogram ; } + { + return m_Histogram ; + } - void Update() - { this->GenerateData() ; } + void Update() + { + this->GenerateData() ; + } itkSetMacro(AutoMinMax,bool); itkGetConstReferenceMacro(AutoMinMax,bool); void SetHistogramMin(const MeasurementVectorType & histogramMin) - { + { m_HistogramMin = histogramMin; m_AutoMinMax = false; - } + } void SetHistogramMax(const MeasurementVectorType & histogramMax) - { + { m_HistogramMax = histogramMax; m_AutoMinMax = false; - } + } protected: @@ -125,7 +134,7 @@ private: } ; // end of class -} // end of namespace itk +} // end of namespace itk #ifndef OTB_MANUAL_INSTANTIATION #include "otbListSampleToVariableDimensionHistogramGenerator.txx" diff --git a/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.txx b/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.txx old mode 100755 new mode 100644 index 02254859a6..23664a59c2 --- a/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.txx +++ b/Code/BasicFilters/otbListSampleToVariableDimensionHistogramGenerator.txx @@ -13,8 +13,8 @@ for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -26,46 +26,46 @@ namespace otb { -template< class TListSample, - class THistogramMeasurement, - class TFrequencyContainer> -ListSampleToVariableDimensionHistogramGenerator< TListSample, - THistogramMeasurement, - TFrequencyContainer > +template< class TListSample, +class THistogramMeasurement, +class TFrequencyContainer> +ListSampleToVariableDimensionHistogramGenerator< TListSample, +THistogramMeasurement, +TFrequencyContainer > ::ListSampleToVariableDimensionHistogramGenerator() { m_Histogram = HistogramType::New() ; m_MarginalScale = 100 ; m_AutoMinMax = true; -} +} -template< class TListSample, - class THistogramMeasurement, - class TFrequencyContainer > +template< class TListSample, +class THistogramMeasurement, +class TFrequencyContainer > void -ListSampleToVariableDimensionHistogramGenerator< TListSample, - THistogramMeasurement, - TFrequencyContainer > +ListSampleToVariableDimensionHistogramGenerator< TListSample, +THistogramMeasurement, +TFrequencyContainer > ::GenerateData() { // TODO : Sanity checks - if(m_Sizes.GetSize() != m_List->GetMeasurementVectorSize()) - { + if (m_Sizes.GetSize() != m_List->GetMeasurementVectorSize()) + { itkExceptionMacro("Sample list measurement vectors and histogram bin sizes vector have different dimensions !"); - } + } - if(!m_AutoMinMax) - { - if(m_HistogramMin.GetSize() != m_List->GetMeasurementVectorSize()) + if (!m_AutoMinMax) + { + if (m_HistogramMin.GetSize() != m_List->GetMeasurementVectorSize()) { - itkExceptionMacro("Sample list measurement vectors and histogram min have different dimensions !"); + itkExceptionMacro("Sample list measurement vectors and histogram min have different dimensions !"); } - if(m_HistogramMax.GetSize() != m_List->GetMeasurementVectorSize()) + if (m_HistogramMax.GetSize() != m_List->GetMeasurementVectorSize()) { - itkExceptionMacro("Sample list measurement vectors and histogram max have different dimensions !"); - } + itkExceptionMacro("Sample list measurement vectors and histogram max have different dimensions !"); } + } typename TListSample::MeasurementVectorType lower(m_List->GetMeasurementVectorSize()); typename TListSample::MeasurementVectorType upper(m_List->GetMeasurementVectorSize()); @@ -76,56 +76,56 @@ ListSampleToVariableDimensionHistogramGenerator< TListSample, // must test for the list size to avoid making FindSampleBound() segfault. // Also, the min and max can't be found automatically in that case. We can // only return an empty histogram - if( m_AutoMinMax && m_List->Size() != 0 ) - { + if ( m_AutoMinMax && m_List->Size() != 0 ) + { FindSampleBound(m_List, m_List->Begin(), m_List->End(), lower, upper) ; - + float margin ; for ( unsigned int i = 0 ; i < m_List->GetMeasurementVectorSize() ; i++ ) - { + { if ( !itk::NumericTraits< THistogramMeasurement >::is_integer ) - { - margin = - ( (THistogramMeasurement)(upper[i] - lower[i]) / - (THistogramMeasurement) m_Sizes[i] ) / - (THistogramMeasurement) m_MarginalScale ; + { + margin = + ( (THistogramMeasurement)(upper[i] - lower[i]) / + (THistogramMeasurement) m_Sizes[i] ) / + (THistogramMeasurement) m_MarginalScale ; h_upper[i] = (THistogramMeasurement) (upper[i] + margin) ; - if(h_upper[i] <= upper[i]) - { + if (h_upper[i] <= upper[i]) + { // an overflow has occurred therefore set upper to upper h_upper[i] = upper[i]; // Histogram measurement type would force the clipping the max value. // Therefore we must call the following to include the max value: m_Histogram->SetClipBinsAtEnds(false); - // The above function is okay since here we are within the autoMinMax + // The above function is okay since here we are within the autoMinMax // computation and clearly the user intended to include min and max. - } } + } else + { + h_upper[i] = ((THistogramMeasurement) upper[i]) + + itk::NumericTraits< THistogramMeasurement >::One ; + if (h_upper[i] <= upper[i]) { - h_upper[i] = ((THistogramMeasurement) upper[i]) + - itk::NumericTraits< THistogramMeasurement >::One ; - if(h_upper[i] <= upper[i]) - { // an overflow has occurred therefore set upper to upper h_upper[i] = upper[i]; // Histogram measurement type would force the clipping the max value. // Therefore we must call the following to include the max value: m_Histogram->SetClipBinsAtEnds(false); - // The above function is okay since here we are within the autoMinMax + // The above function is okay since here we are within the autoMinMax // computation and clearly the user intended to include min and max. - } } - h_lower[i] = ( THistogramMeasurement) lower[i] ; } + h_lower[i] = ( THistogramMeasurement) lower[i] ; } + } else - { + { h_lower = m_HistogramMin; h_upper = m_HistogramMax; - } + } // initialize the Histogram object using the sizes and // the upper and lower bound from the FindSampleBound function @@ -138,16 +138,16 @@ ListSampleToVariableDimensionHistogramGenerator< TListSample, typename HistogramType::MeasurementVectorType hvector(m_List->GetMeasurementVectorSize()) ; unsigned int i; while (iter != last) - { + { lvector = iter.GetMeasurementVector() ; for ( i = 0 ; i < m_List->GetMeasurementVectorSize() ; i++) - { + { hvector[i] = (THistogramMeasurement) lvector[i] ; - } + } m_Histogram->GetIndex(hvector,index); if (!m_Histogram->IsIndexOutOfBounds(index)) - { + { // if the measurement vector is out of bound then // the GetIndex method has returned an index set to the max size of // the invalid dimension - even if the hvector is less than the minimum @@ -155,18 +155,18 @@ ListSampleToVariableDimensionHistogramGenerator< TListSample, // If the index isn't valid, we don't increase the frequency. // See the comments in Histogram->GetIndex() for more info. m_Histogram->IncreaseFrequency(index, 1) ; - } - ++iter ; } + ++iter ; + } } -template< class TListSample, - class THistogramMeasurement, - class TFrequencyContainer > +template< class TListSample, +class THistogramMeasurement, +class TFrequencyContainer > void -ListSampleToVariableDimensionHistogramGenerator< TListSample, - THistogramMeasurement, - TFrequencyContainer > +ListSampleToVariableDimensionHistogramGenerator< TListSample, +THistogramMeasurement, +TFrequencyContainer > ::PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os,indent); @@ -177,7 +177,7 @@ ListSampleToVariableDimensionHistogramGenerator< TListSample, os << indent << "HistogramMax: "<< m_HistogramMax << std::endl; } -} // end of namespace itk +} // end of namespace itk #endif diff --git a/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.h b/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.h index d8a2e05abc..6f3a8ff0f8 100644 --- a/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.h +++ b/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.h @@ -55,7 +55,7 @@ public: /** "typedef" to simplify the variables definition and the declaration. */ typedef TInputImage InputImageType; typedef TOutputImage OutputImageType; - + /** Supported images definition. */ typedef typename InputImageType::PixelType InputPixelType; typedef typename InputImageType::InternalPixelType InputInternalPixelType; diff --git a/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.txx b/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.txx index 55d51bd01f..fab4b346bf 100644 --- a/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.txx +++ b/Code/BasicFilters/otbNormalizeInnerProductPCAImageFilter.txx @@ -46,7 +46,7 @@ template<class TInputImage, class TOutputImage> void NormalizeInnerProductPCAImageFilter<TInputImage,TOutputImage> ::GenerateOutputInformation(void) -{ +{ Superclass::GenerateOutputInformation(); } @@ -65,13 +65,13 @@ NormalizeInnerProductPCAImageFilter<TInputImage,TOutputImage> RealPixelType means = stats->GetMean(); MatrixType cov = stats->GetCovariance(); double NbPixels = static_cast<double>(this->GetInput()->GetLargestPossibleRegion().GetSize()[0] * this->GetInput()->GetLargestPossibleRegion().GetSize()[1]); - if( (cov.Rows() != means.Size()) || (cov.Cols() != means.Size()) ) + if ( (cov.Rows() != means.Size()) || (cov.Cols() != means.Size()) ) { itkExceptionMacro( << "Covariance matrix with size (" << cov.Rows() << "," << - cov.Cols() << ") is incompatible with mean vector with size" << means.Size() ); + cov.Cols() << ") is incompatible with mean vector with size" << means.Size() ); } m_CoefNorm.SetSize(means.Size()); - for(unsigned int i=0 ; i<m_CoefNorm.Size() ; i++) + for (unsigned int i=0 ; i<m_CoefNorm.Size() ; i++) { m_CoefNorm[i] = (1./vcl_sqrt(NbPixels*(cov[i][i] + means[i]*means[i]))); } @@ -109,7 +109,7 @@ NormalizeInnerProductPCAImageFilter<TInputImage,TOutputImage> //outPixel = m_Means * inPixel; for (unsigned int j=0; j<inputPtr->GetNumberOfComponentsPerPixel(); j++) { - outPixel[j] = static_cast<OutputInternalPixelType>(m_CoefNorm[j]*static_cast<double>(inPixel[j])); + outPixel[j] = static_cast<OutputInternalPixelType>(m_CoefNorm[j]*static_cast<double>(inPixel[j])); } outputIt.Set(outPixel); diff --git a/Code/BasicFilters/otbStreamingInnerProductVectorImageFilter.txx b/Code/BasicFilters/otbStreamingInnerProductVectorImageFilter.txx index 8391875195..248572369e 100644 --- a/Code/BasicFilters/otbStreamingInnerProductVectorImageFilter.txx +++ b/Code/BasicFilters/otbStreamingInnerProductVectorImageFilter.txx @@ -149,42 +149,42 @@ void PersistentInnerProductVectorImageFilter<TInputImage> ::Synthetize() { - // Compute Inner product Matrix - TInputImage * inputPtr = const_cast<TInputImage * >(this->GetInput()); - unsigned int numberOfTrainingImages = inputPtr->GetNumberOfComponentsPerPixel(); - unsigned int numberOfThreads = this->GetNumberOfThreads(); - MatrixType innerProduct; - innerProduct.set_size( numberOfTrainingImages, numberOfTrainingImages ); - innerProduct.fill( 0 ); - - // Concatenate threaded matrix - for ( unsigned int thread = 0; thread < numberOfThreads; thread++) - { - innerProduct += m_ThreadInnerProduct[thread]; - } + // Compute Inner product Matrix + TInputImage * inputPtr = const_cast<TInputImage * >(this->GetInput()); + unsigned int numberOfTrainingImages = inputPtr->GetNumberOfComponentsPerPixel(); + unsigned int numberOfThreads = this->GetNumberOfThreads(); + MatrixType innerProduct; + innerProduct.set_size( numberOfTrainingImages, numberOfTrainingImages ); + innerProduct.fill( 0 ); - //--------------------------------------------------------------------- - // Fill the rest of the inner product matrix and make it symmetric - //--------------------------------------------------------------------- - for(unsigned int band_x = 0; band_x < (numberOfTrainingImages - 1); band_x++) - { - for(unsigned int band_y = band_x+1; band_y < numberOfTrainingImages; band_y++) - { - innerProduct[band_x][band_y] = innerProduct[band_y][band_x]; - }// end band_y loop - }// end band_x loop + // Concatenate threaded matrix + for ( unsigned int thread = 0; thread < numberOfThreads; thread++) + { + innerProduct += m_ThreadInnerProduct[thread]; + } - if( ( numberOfTrainingImages - 1 ) != 0 ) - { - innerProduct /= ( numberOfTrainingImages - 1 ); - } - else + //--------------------------------------------------------------------- + // Fill the rest of the inner product matrix and make it symmetric + //--------------------------------------------------------------------- + for (unsigned int band_x = 0; band_x < (numberOfTrainingImages - 1); band_x++) + { + for (unsigned int band_y = band_x+1; band_y < numberOfTrainingImages; band_y++) { - innerProduct.fill(0); - } + innerProduct[band_x][band_y] = innerProduct[band_y][band_x]; + }// end band_y loop + }// end band_x loop - // Set the output - this->GetInnerProductOutput()->Set( innerProduct ); + if ( ( numberOfTrainingImages - 1 ) != 0 ) + { + innerProduct /= ( numberOfTrainingImages - 1 ); + } + else + { + innerProduct.fill(0); + } + + // Set the output + this->GetInnerProductOutput()->Set( innerProduct ); } template<class TInputImage> @@ -195,36 +195,36 @@ PersistentInnerProductVectorImageFilter<TInputImage> /** * Grab the input */ - InputImagePointer inputPtr = const_cast< TInputImage * >( this->GetInput() ); - // support progress methods/callbacks - itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - unsigned int numberOfTrainingImages = inputPtr->GetNumberOfComponentsPerPixel(); - - itk::ImageRegionConstIterator<TInputImage> it (inputPtr, outputRegionForThread); - it.GoToBegin(); - // do the work - while (!it.IsAtEnd()) + InputImagePointer inputPtr = const_cast< TInputImage * >( this->GetInput() ); + // support progress methods/callbacks + itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); + unsigned int numberOfTrainingImages = inputPtr->GetNumberOfComponentsPerPixel(); + + itk::ImageRegionConstIterator<TInputImage> it (inputPtr, outputRegionForThread); + it.GoToBegin(); + // do the work + while (!it.IsAtEnd()) + { + PixelType vectorValue = it.Get(); + double mean(0.); + for (unsigned int i=0; i<vectorValue.GetSize(); i++) + { + mean += static_cast<double>(vectorValue[i]); + } + mean /= static_cast<double>(vectorValue.GetSize()); + + // Matrix iteration + for (unsigned int band_x = 0; band_x < numberOfTrainingImages; band_x++) { - PixelType vectorValue = it.Get(); - double mean(0.); - for (unsigned int i=0; i<vectorValue.GetSize(); i++) - { - mean += static_cast<double>(vectorValue[i]); - } - mean /= static_cast<double>(vectorValue.GetSize()); - - // Matrix iteration - for(unsigned int band_x = 0; band_x < numberOfTrainingImages; band_x++) - { - for(unsigned int band_y = 0; band_y <= band_x; band_y++ ) - { - m_ThreadInnerProduct[threadId][band_x][band_y] += - (static_cast<double>(vectorValue[band_x]) - mean) * (static_cast<double>(vectorValue[band_y]) - mean); - } // end: band_y loop - } // end: band_x loop - ++it; - progress.CompletedPixel(); - }// end: looping through the image + for (unsigned int band_y = 0; band_y <= band_x; band_y++ ) + { + m_ThreadInnerProduct[threadId][band_x][band_y] += + (static_cast<double>(vectorValue[band_x]) - mean) * (static_cast<double>(vectorValue[band_y]) - mean); + } // end: band_y loop + } // end: band_x loop + ++it; + progress.CompletedPixel(); + }// end: looping through the image } template <class TImage> diff --git a/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.h b/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.h index 4d69576219..5a17041ca6 100644 --- a/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.h +++ b/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.h @@ -34,7 +34,7 @@ namespace otb */ template <class TInputList, class TOutputList, class TFunction > class ITK_EXPORT UnaryFunctorObjectListBooleanFilter : - public otb::ObjectListToObjectListFilter<TInputList,TOutputList> + public otb::ObjectListToObjectListFilter<TInputList,TOutputList> { public: /** Standard class typedefs. */ diff --git a/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.txx b/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.txx index 234a880411..6e0ddeffe5 100644 --- a/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.txx +++ b/Code/BasicFilters/otbUnaryFunctorObjectListBooleanFilter.txx @@ -35,9 +35,9 @@ UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction> template <class TInputList, class TOutputList, class TFunction > - void - UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction> - ::ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex,int threadId) +void +UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction> +::ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex,int threadId) { InputListPointer inputPtr = this->GetInput(); @@ -70,9 +70,9 @@ template <class TInputList, class TOutputList, class TFunction > template <class TInputList, class TOutputList, class TFunction > - void - UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction> - ::AfterThreadedGenerateData() +void +UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction> +::AfterThreadedGenerateData() { // copy the lists to the output OutputListPointer outputPtr = this->GetOutput(); diff --git a/Code/BasicFilters/otbUnaryFunctorObjectListFilter.h b/Code/BasicFilters/otbUnaryFunctorObjectListFilter.h index 920700e877..a5bd972ae6 100644 --- a/Code/BasicFilters/otbUnaryFunctorObjectListFilter.h +++ b/Code/BasicFilters/otbUnaryFunctorObjectListFilter.h @@ -34,7 +34,7 @@ namespace otb */ template <class TInputList, class TOutputList, class TFunction > class ITK_EXPORT UnaryFunctorObjectListFilter : - public otb::ObjectListToObjectListFilter<TInputList,TOutputList> + public otb::ObjectListToObjectListFilter<TInputList,TOutputList> { public: /** Standard class typedefs. */ diff --git a/Code/Common/otbDrawLineSpatialObjectFilter.h b/Code/Common/otbDrawLineSpatialObjectFilter.h index 521b49f7d1..191d1043e4 100644 --- a/Code/Common/otbDrawLineSpatialObjectFilter.h +++ b/Code/Common/otbDrawLineSpatialObjectFilter.h @@ -40,8 +40,8 @@ namespace otb template <class TInputImage, class TOutputImage> class ITK_EXPORT DrawLineSpatialObjectFilter : - //public itk::SpatialObjectToImageFilter< itk::LineSpatialObject<2>, TOutputImage > - public itk::ImageToImageFilter<TInputImage, TOutputImage > + //public itk::SpatialObjectToImageFilter< itk::LineSpatialObject<2>, TOutputImage > + public itk::ImageToImageFilter<TInputImage, TOutputImage > { public: /** Extract dimensions as well of the images of entry of exit. */ @@ -61,16 +61,16 @@ public: /** Method for management of the "object factory". */ itkNewMacro(Self); - + /** Return the name of the class. */ itkTypeMacro(DrawLineSpatialObjectFilter, /*SpatialObjectToImageFilter*/itk::ImageToImageFilter); - + /** typedef Support for input & output image*/ typedef TInputImage InputImageType; typedef TOutputImage OutputImageType; typedef typename OutputImageType::PixelType OutputPixelType; - + /** Support typedef for input & Output*/ typedef itk::LineSpatialObject<2> InputLineType; typedef itk::ProcessObject ProcessObjectType; @@ -83,7 +83,7 @@ public: typedef otb::DrawLineSpatialObjectListFilter<InputImageType,OutputImageType > DrawLineSpatialObjectListFilterType; typedef typename DrawLineSpatialObjectListFilterType::Pointer DrawLineSpatialObjectListFilterPointerType; - + /** Set/Get the image input of this process object. */ /* virtual void SetInputImage(const InputImageType *image); */ /* const InputImageType * GetInputImage(void); */ @@ -92,7 +92,7 @@ public: virtual void SetInputLine(const InputLineType *line); InputLineType * GetInputLine(void); - + /** Set/Get pixel value */ itkSetMacro(Value, OutputPixelType); itkGetConstReferenceMacro(Value, OutputPixelType); diff --git a/Code/Common/otbDrawLineSpatialObjectFilter.txx b/Code/Common/otbDrawLineSpatialObjectFilter.txx index 9c0328384f..4b003df1bc 100644 --- a/Code/Common/otbDrawLineSpatialObjectFilter.txx +++ b/Code/Common/otbDrawLineSpatialObjectFilter.txx @@ -74,9 +74,9 @@ DrawLineSpatialObjectFilter<TInputImage, TOutputImage> typename InputImageType::ConstPointer input = this->GetInput(); InputLineType * line = this->GetInputLine(); - + typename OutputImageType::Pointer output = this->GetOutput(); - + /** Create a new list line with one line*/ LineSpatialObjectListPointer lineList = LineSpatialObjectListType::New(); lineList->push_back(line); @@ -84,11 +84,11 @@ DrawLineSpatialObjectFilter<TInputImage, TOutputImage> /** Invoke the DrawLineSpatialObjectListFilter to draw the line */ m_DrawLineListFilter->SetInput(input); m_DrawLineListFilter->SetInputLineSpatialObjectList(lineList); - + m_DrawLineListFilter->GraftOutput(this->GetOutput()); m_DrawLineListFilter->Update(); this->GraftOutput(m_DrawLineListFilter->GetOutput()); - + } diff --git a/Code/Common/otbDrawLineSpatialObjectListFilter.h b/Code/Common/otbDrawLineSpatialObjectListFilter.h index 5ada193180..4d93180788 100644 --- a/Code/Common/otbDrawLineSpatialObjectListFilter.h +++ b/Code/Common/otbDrawLineSpatialObjectListFilter.h @@ -28,8 +28,8 @@ namespace otb * \brief Composite filter which draw lines in an image. * * This class implements a composite filter that draws a list of lines in - * an input Image. This class - * + * an input Image. This class + * * * */ @@ -47,7 +47,7 @@ public: unsigned int, TOutputImage::ImageDimension); - + /** typedefs support for inputs & outputs*/ typedef TInputImage InputImageType; typedef TOutputImage OutputImageType; @@ -86,30 +86,30 @@ public: /** Get/Set m_Value*/ itkGetMacro(Value,OutputPixelType ); itkSetMacro(Value,OutputPixelType ); - - + + protected: DrawLineSpatialObjectListFilter(); virtual ~DrawLineSpatialObjectListFilter() {}; void PrintSelf(std::ostream& os, itk::Indent indent) const; virtual void ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, int threadId ) ; - + /** * compute the intersection of the segment to draw with the region */ virtual void CropSegment(OutputIndexType *indexToCrop,OutputIndexType *otherIndex, const OutputImageRegionType *outputRegionForThread )const; - + virtual void CropRightSegment(OutputIndexType *indexToCrop,OutputIndexType *otherIndex, const OutputImageRegionType *outputRegionForThread )const; - + virtual bool IsUpsideTheRegion(OutputIndexType *indexToCrop, const OutputImageRegionType *outputRegionForThread ) const; virtual bool IsDownsideTheRegion(OutputIndexType *indexToCrop, const OutputImageRegionType *outputRegionForThread )const; - + virtual bool IsDownsideTheImage(OutputIndexType *indexToCrop )const; - - + + virtual bool IsColumnOutsideOfTheRegion(OutputIndexType *indexToCheck, OutputIndexType *otherToCheck, const OutputImageRegionType *outputRegionForThread)const; private: diff --git a/Code/Common/otbDrawLineSpatialObjectListFilter.txx b/Code/Common/otbDrawLineSpatialObjectListFilter.txx index f171477f71..57a9f0fcdc 100644 --- a/Code/Common/otbDrawLineSpatialObjectListFilter.txx +++ b/Code/Common/otbDrawLineSpatialObjectListFilter.txx @@ -72,20 +72,20 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutputImage> typename InputImageType::ConstPointer input = this->GetInput(); typename OutputImageType::Pointer output = this->GetOutput(); typename LinesListType::Pointer list = const_cast<LinesListType*>(this->GetInputLineSpatialObjectList()); - + /** Copy the input requested region in the output requested region*/ typedef itk::ImageRegionIterator< OutputImageType > OutputIteratorType; typedef itk::ImageRegionConstIterator< InputImageType > InputIteratorType; OutputIteratorType outputIt( output, outputRegionForThread); InputIteratorType inputIt( input, outputRegionForThread); - + outputIt.GoToBegin(); inputIt.GoToBegin(); for (outputIt.GoToBegin(); !outputIt.IsAtEnd() ; ++outputIt,++inputIt) - outputIt.Set( static_cast<OutputPixelType>(inputIt.Get()) ); - + outputIt.Set( static_cast<OutputPixelType>(inputIt.Get()) ); + /** Draw the lines in the ouput image using lineIterator*/ typedef itk::LineIterator<OutputImageType> LineIteratorFilter; OutputIndexType indexBeginLine, indexEndLine; @@ -94,66 +94,66 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutputImage> typename InputImageType::SizeType size = input->GetLargestPossibleRegion().GetSize(); m_Length = size[1]; m_Width = size[0]; - - - - while(itList != list->end()) + + + + while (itList != list->end()) + { + PointListType & pointsList = (*itList)->GetPoints(); + typename PointListType::const_iterator itPoints = pointsList.begin(); + + indexBeginLine[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); + indexBeginLine[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); + + ++itPoints; //Get the second extremity of the segment + + indexEndLine[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); + indexEndLine[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); + + + /** Crop the segment if it is outside the region in the left*/ + + if ( !(this->IsColumnOutsideOfTheRegion(&indexBeginLine,&indexEndLine,&outputRegionForThread) && this->IsColumnOutsideOfTheRegion(&indexEndLine,&indexBeginLine,&outputRegionForThread))) + { + if (indexEndLine[0] >=static_cast< int>(size[0])) + this->CropRightSegment(&indexEndLine,&indexBeginLine, &outputRegionForThread); + + if ( indexBeginLine[0] >= static_cast< int>(size[0]) ) + this->CropRightSegment(&indexBeginLine,&indexEndLine, &outputRegionForThread); + } + + /** + * If an extremity is under the region + * Technically, the X component of the index is inside the image + */ + if (this->IsDownsideTheImage(&indexBeginLine) && input->GetLargestPossibleRegion().IsInside(indexEndLine)) + this->CropSegment(&indexBeginLine,&indexEndLine, &outputRegionForThread); + + if (this->IsDownsideTheImage(&indexEndLine) && input->GetLargestPossibleRegion().IsInside(indexBeginLine)) + this->CropSegment(&indexEndLine,&indexBeginLine, &outputRegionForThread); + + + /** If the segments are not in the region (upside or downside the region)*/ + if (!(this->IsUpsideTheRegion(&indexBeginLine,&outputRegionForThread) && this->IsUpsideTheRegion(&indexEndLine,&outputRegionForThread)) && + !(this->IsDownsideTheRegion(&indexBeginLine,&outputRegionForThread) && this->IsDownsideTheRegion(&indexEndLine,&outputRegionForThread)) && + !(this->IsColumnOutsideOfTheRegion(&indexBeginLine,&indexEndLine, &outputRegionForThread) && this->IsColumnOutsideOfTheRegion(&indexEndLine,&indexBeginLine,&outputRegionForThread)) + ) { - PointListType & pointsList = (*itList)->GetPoints(); - typename PointListType::const_iterator itPoints = pointsList.begin(); - - indexBeginLine[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); - indexBeginLine[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); - - ++itPoints; //Get the second extremity of the segment - - indexEndLine[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); - indexEndLine[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); - - - /** Crop the segment if it is outside the region in the left*/ - - if( !(this->IsColumnOutsideOfTheRegion(&indexBeginLine,&indexEndLine,&outputRegionForThread) && this->IsColumnOutsideOfTheRegion(&indexEndLine,&indexBeginLine,&outputRegionForThread))) - { - if(indexEndLine[0] >=static_cast< int>(size[0])) - this->CropRightSegment(&indexEndLine,&indexBeginLine, &outputRegionForThread); - - if( indexBeginLine[0] >= static_cast< int>(size[0]) ) - this->CropRightSegment(&indexBeginLine,&indexEndLine, &outputRegionForThread); - } - - /** - * If an extremity is under the region - * Technically, the X component of the index is inside the image - */ - if(this->IsDownsideTheImage(&indexBeginLine) && input->GetLargestPossibleRegion().IsInside(indexEndLine)) - this->CropSegment(&indexBeginLine,&indexEndLine, &outputRegionForThread); - - if(this->IsDownsideTheImage(&indexEndLine) && input->GetLargestPossibleRegion().IsInside(indexBeginLine)) - this->CropSegment(&indexEndLine,&indexBeginLine, &outputRegionForThread); - - - /** If the segments are not in the region (upside or downside the region)*/ - if(!(this->IsUpsideTheRegion(&indexBeginLine,&outputRegionForThread) && this->IsUpsideTheRegion(&indexEndLine,&outputRegionForThread)) && - !(this->IsDownsideTheRegion(&indexBeginLine,&outputRegionForThread) && this->IsDownsideTheRegion(&indexEndLine,&outputRegionForThread)) && - !(this->IsColumnOutsideOfTheRegion(&indexBeginLine,&indexEndLine, &outputRegionForThread) && this->IsColumnOutsideOfTheRegion(&indexEndLine,&indexBeginLine,&outputRegionForThread)) - ) - { - - /** Instanciation of the line iterator with begin and ending index*/ - LineIteratorFilter itLine(output,indexBeginLine ,indexEndLine ); - - /** Iteration over the line and writing white lines */ - while(!itLine.IsAtEnd()) - { - if(outputRegionForThread.IsInside(itLine.GetIndex())) - itLine.Set(m_Value); - ++itLine; - } - } - - ++itList; + + /** Instanciation of the line iterator with begin and ending index*/ + LineIteratorFilter itLine(output,indexBeginLine ,indexEndLine ); + + /** Iteration over the line and writing white lines */ + while (!itLine.IsAtEnd()) + { + if (outputRegionForThread.IsInside(itLine.GetIndex())) + itLine.Set(m_Value); + ++itLine; + } } + + ++itList; + } } @@ -169,17 +169,17 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutput> { - /** Dimensions of the buffered region*/ - typename OutputImageRegionType::SizeType size = outputRegionForThread->GetSize(); - typename OutputImageRegionType::IndexType start = outputRegionForThread->GetIndex(); - - /** Equation of the line (Begin, End)*/ - double lengthSegment = -(*otherIndex)[1] + (*indexToCrop)[1]; - double slope = lengthSegment/( (*indexToCrop)[0] - (*otherIndex)[0]); - double origin = (*otherIndex)[1] - (slope * (*otherIndex)[0]); - - (*indexToCrop)[0] = static_cast<unsigned int>(size[0]-1); - (*indexToCrop)[1] = static_cast<unsigned int>(slope *(*indexToCrop)[0] + origin +0.5) ; + /** Dimensions of the buffered region*/ + typename OutputImageRegionType::SizeType size = outputRegionForThread->GetSize(); + typename OutputImageRegionType::IndexType start = outputRegionForThread->GetIndex(); + + /** Equation of the line (Begin, End)*/ + double lengthSegment = -(*otherIndex)[1] + (*indexToCrop)[1]; + double slope = lengthSegment/( (*indexToCrop)[0] - (*otherIndex)[0]); + double origin = (*otherIndex)[1] - (slope * (*otherIndex)[0]); + + (*indexToCrop)[0] = static_cast<unsigned int>(size[0]-1); + (*indexToCrop)[1] = static_cast<unsigned int>(slope *(*indexToCrop)[0] + origin +0.5) ; } /** @@ -231,7 +231,7 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutput> /** - * + * * */ template <class TInputImage, class TOutput> @@ -242,18 +242,18 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutput> /** Dimensions of the buffered region*/ typename OutputImageRegionType::SizeType size = outputRegionForThread->GetSize(); bool res = false, res1= false , res2 = false; - + if ( ((*indexToCheck)[0]>=static_cast< int>(size[0])) && ((*otherToCheck)[0]>=static_cast< int>(size[0]) )) res = true; - - if((*indexToCheck)[0]>=static_cast< int>(size[0]) && this->IsUpsideTheRegion(otherToCheck,outputRegionForThread)) + + if ((*indexToCheck)[0]>=static_cast< int>(size[0]) && this->IsUpsideTheRegion(otherToCheck,outputRegionForThread)) res1 = true; - - if((*indexToCheck)[0]>=static_cast< int>(size[0]) && this->IsDownsideTheRegion(otherToCheck,outputRegionForThread) ) + + if ((*indexToCheck)[0]>=static_cast< int>(size[0]) && this->IsDownsideTheRegion(otherToCheck,outputRegionForThread) ) res2 = true; - + return res || res1 || res2; } @@ -271,7 +271,7 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutput> { OutputIndexType tempIndex; tempIndex = *indexToCrop; - + /** Dimensions of the buffered region*/ typename OutputImageRegionType::SizeType size = outputRegionForThread->GetSize(); typename OutputImageRegionType::IndexType start = outputRegionForThread->GetIndex(); @@ -281,37 +281,37 @@ DrawLineSpatialObjectListFilter<TInputImage, TOutput> double lengthSegment =0.; double origin = 0.; double tempOtherIndexX= 0.; - + /** Equation of the first Line*/ - if(vcl_abs( (*otherIndex)[0] -(*indexToCrop)[0] ) <1e-4) + if (vcl_abs( (*otherIndex)[0] -(*indexToCrop)[0] ) <1e-4) tempOtherIndexX= 0.000001; else tempOtherIndexX = static_cast<double>((*otherIndex)[0]); - if( (*indexToCrop)[0] < (*otherIndex)[0]) + if ( (*indexToCrop)[0] < (*otherIndex)[0]) lengthSegment = (*otherIndex)[1] -(*indexToCrop)[1]; - else + else lengthSegment = (*indexToCrop)[1] -(*otherIndex)[1]; - + slope = lengthSegment/( tempOtherIndexX - static_cast<double>((*indexToCrop)[0])); origin = (*indexToCrop)[1] - (slope * static_cast<double>((*indexToCrop)[0])); - - if((*indexToCrop)[1] < 0) - { - unsigned int Y = 0; - tempIndex[1] = Y; - tempIndex[0] = static_cast<unsigned int>((Y-origin) / slope); // X = (Y-B)/A - } - - if(this->IsDownsideTheImage(indexToCrop )) - { - double Y = static_cast<double>(m_Length-1)/*tstart[1]+size[1]-1*/; - tempIndex[1] = static_cast<unsigned int>(Y); - tempIndex[0] = static_cast<unsigned int>((Y-origin) / slope); // X = (Y-B)/A - } + + if ((*indexToCrop)[1] < 0) + { + unsigned int Y = 0; + tempIndex[1] = Y; + tempIndex[0] = static_cast<unsigned int>((Y-origin) / slope); // X = (Y-B)/A + } + + if (this->IsDownsideTheImage(indexToCrop )) + { + double Y = static_cast<double>(m_Length-1)/*tstart[1]+size[1]-1*/; + tempIndex[1] = static_cast<unsigned int>(Y); + tempIndex[0] = static_cast<unsigned int>((Y-origin) / slope); // X = (Y-B)/A + } (*indexToCrop)[0] = tempIndex[0]; (*indexToCrop)[1] = tempIndex[1]; diff --git a/Code/Common/otbLineSpatialObjectListToPointSetFilter.h b/Code/Common/otbLineSpatialObjectListToPointSetFilter.h index dcf439fc25..57ebcfe200 100644 --- a/Code/Common/otbLineSpatialObjectListToPointSetFilter.h +++ b/Code/Common/otbLineSpatialObjectListToPointSetFilter.h @@ -56,10 +56,10 @@ public: /** Some convenient typedefs. */ typedef TLinesList LinesListType; typedef typename LinesListType::LineType LineType; - + /** typedef support for output*/ typedef TPointSet PointSetType; - + typedef itk::ProcessObject ProcessObjectType; /** Set/Get the input image */ @@ -82,7 +82,7 @@ private: LineSpatialObjectListToPointSetFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented - + diff --git a/Code/Common/otbPolyLineParametricPathWithValue.h b/Code/Common/otbPolyLineParametricPathWithValue.h index 7c87da7fb4..72f416014f 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.h +++ b/Code/Common/otbPolyLineParametricPathWithValue.h @@ -33,10 +33,10 @@ namespace otb * \sa itk::PolyLineParametricPath. */ template < class TValue,unsigned int VDimension=2> - class ITK_EXPORT PolyLineParametricPathWithValue - : public itk::PolyLineParametricPath<VDimension> +class ITK_EXPORT PolyLineParametricPathWithValue + : public itk::PolyLineParametricPath<VDimension> { - public: +public: /** Standard typedefs */ typedef PolyLineParametricPathWithValue Self; typedef itk::PolyLineParametricPath<VDimension> Superclass; @@ -93,12 +93,12 @@ template < class TValue,unsigned int VDimension=2> void AddVertex (const ContinuousIndexType &vertex); - /** - * Compute the path bounding region. - * \return The region. - */ + /** + * Compute the path bounding region. + * \return The region. + */ RegionType GetBoundingRegion(void); - + protected: /** Constructor */ PolyLineParametricPathWithValue(); @@ -109,7 +109,7 @@ protected: virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; virtual void ComputeLength() const; - + private: PolyLineParametricPathWithValue(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented diff --git a/Code/Common/otbPolyLineParametricPathWithValue.txx b/Code/Common/otbPolyLineParametricPathWithValue.txx index 962a33c2bc..1571581f90 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.txx +++ b/Code/Common/otbPolyLineParametricPathWithValue.txx @@ -56,7 +56,7 @@ double PolyLineParametricPathWithValue<TValue,VDimension> } template < class TValue,unsigned int VDimension> -void +void PolyLineParametricPathWithValue<TValue,VDimension> ::ComputeLength() const { @@ -119,7 +119,7 @@ PolyLineParametricPathWithValue<TValue,VDimension> template < class TValue,unsigned int VDimension> typename PolyLineParametricPathWithValue<TValue,VDimension> ::RegionType -PolyLineParametricPathWithValue<TValue,VDimension> +PolyLineParametricPathWithValue<TValue,VDimension> ::GetBoundingRegion() { RegionType region; diff --git a/Code/Common/otbPolygon.txx b/Code/Common/otbPolygon.txx index cbcf7658a4..879afdd13d 100644 --- a/Code/Common/otbPolygon.txx +++ b/Code/Common/otbPolygon.txx @@ -468,9 +468,9 @@ Polygon<TValue> * Get surface */ template<class TValue> - double - Polygon<TValue> - ::GetArea() const +double +Polygon<TValue> +::GetArea() const { if (!m_AreaIsValid) { diff --git a/Code/Common/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.txx b/Code/Common/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.txx index ac9a423ed5..f20b8047bf 100644 --- a/Code/Common/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.txx +++ b/Code/Common/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.txx @@ -128,7 +128,7 @@ UnaryFunctorNeighborhoodWithOffsetImageFilter<TInputImage, TOutputImage, TFuncti OutputImagePointer outputPtr = this->GetOutput(0); itk::ImageRegionIterator<TOutputImage> outputIt; - + // Neighborhood+offset iterator RadiusType rOff; rOff[0] = m_Radius + vcl_abs(m_Offset[0]); diff --git a/Code/Common/otbVectorDataExtractROI.h b/Code/Common/otbVectorDataExtractROI.h index bbeeef948b..43180e13ac 100644 --- a/Code/Common/otbVectorDataExtractROI.h +++ b/Code/Common/otbVectorDataExtractROI.h @@ -50,29 +50,29 @@ public: /** Image type information. */ typedef TVectorData VectorDataType; typedef typename VectorDataType::DataTreeType DataTreeType; - + /** Get/Set Macro for ROI Column size */ itkGetMacro(SizeX, unsigned int); itkSetMacro(SizeX, unsigned int); - + /** Get/Set Macro for ROI Lines size */ itkGetMacro(SizeY, unsigned int); itkSetMacro(SizeY, unsigned int); - + /** Get/Set Macro for ROI Start Point Coordinate */ itkGetMacro(StartX, unsigned int); itkSetMacro(StartX, unsigned int); - + /** Get/Set Macro for ROI Start Point Abcisse */ itkGetMacro(StartY, unsigned int); - itkSetMacro(StartY, unsigned int); + itkSetMacro(StartY, unsigned int); + - /** Prototype of the generate data method*/ void GenerateData(void ); - - + + protected: VectorDataExtractROI(); @@ -92,7 +92,7 @@ private: unsigned int m_SizeY; unsigned int m_StartX; unsigned int m_StartY; - + }; diff --git a/Code/Common/otbVectorDataExtractROI.txx b/Code/Common/otbVectorDataExtractROI.txx index f545a6c08d..52aa6ba775 100644 --- a/Code/Common/otbVectorDataExtractROI.txx +++ b/Code/Common/otbVectorDataExtractROI.txx @@ -40,8 +40,8 @@ VectorDataExtractROI<TVectorData> m_StartX = 0; m_StartY = 0; - - + + } /** @@ -60,7 +60,7 @@ VectorDataExtractROI<TVectorData> * VectorDataExtractROI can produce an output vector data which is different depth * than the input vectorData * As such, VectorDataExtractROI have to provide an implementation for GenerateOutputInformation - * in order to inform the pipeline execution model. + * in order to inform the pipeline execution model. * \sa ProcessObject::GenerateOutputInformaton() */ // template <class TVectorData> @@ -79,15 +79,15 @@ VectorDataExtractROI<TVectorData> { /** Get The input and the outptut*/ typename VectorDataType::ConstPointer input = this->GetInput(); - if(!input) + if (!input) std::cout << " Probleme avec la recuperation du input"<<std::endl; - + /** Create a region with the right size*/ const unsigned int Dimension = 2; typedef itk::ImageRegion<Dimension> ImageRegionType; typedef itk::Index<Dimension> IndexType; typedef itk::Size<Dimension> SizeType; - + /** */ ImageRegionType roi; IndexType index; @@ -102,7 +102,7 @@ VectorDataExtractROI<TVectorData> /** Create the region*/ roi.SetSize(size); roi.SetIndex(index); - + /** Loop in the vectorData file*/ typedef itk::PreOrderTreeIterator<DataTreeType> TreeIteratorType; TreeIteratorType it(input->GetDataTree()); @@ -110,19 +110,19 @@ VectorDataExtractROI<TVectorData> it.GoToBegin(); while (!it.IsAtEnd()) { - + itk::PreOrderTreeIterator<DataTreeType> itParent = it; bool goesOn = true; if (it.Get()->IsPolygonFeature()) std::cout << " C'est un polygone et les coordonnees " << it.Get()->GetPolygonExteriorRing()->GetVertexList()->GetElement(0) << std::endl; - + if (it.Get()->IsLineFeature()) - std::cout << "Vertex List Size " << it.Get()->GetLine()->GetVertexList()->Size() <<std::endl; + std::cout << "Vertex List Size " << it.Get()->GetLine()->GetVertexList()->Size() <<std::endl; if (it.Get()->IsPointFeature()) std::cout << " C'est un point" << std::endl; - + ++it; } diff --git a/Code/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h b/Code/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h old mode 100755 new mode 100644 index 0abf087341..45e4bc2d78 --- a/Code/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h +++ b/Code/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h @@ -38,11 +38,11 @@ namespace Functor */ template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT AngularSecondMomentumTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - AngularSecondMomentumTextureFunctor(){}; - virtual ~AngularSecondMomentumTextureFunctor(){}; + AngularSecondMomentumTextureFunctor() {}; + virtual ~AngularSecondMomentumTextureFunctor() {}; typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -56,15 +56,15 @@ public: double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); double areaInv = 1/area; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; - out += vcl_pow( p, 2 ); - } - } - return out; + for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; + out += vcl_pow( p, 2 ); + } + } + return out; } }; diff --git a/Code/FeatureExtraction/otbClusterProminenceTextureFunctor.h b/Code/FeatureExtraction/otbClusterProminenceTextureFunctor.h old mode 100755 new mode 100644 index 7ab3e3ae04..4c207d859b --- a/Code/FeatureExtraction/otbClusterProminenceTextureFunctor.h +++ b/Code/FeatureExtraction/otbClusterProminenceTextureFunctor.h @@ -41,12 +41,12 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT ClusterProminenceTextureFunctor : -public MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: - ClusterProminenceTextureFunctor(){}; - virtual ~ClusterProminenceTextureFunctor(){}; - + ClusterProminenceTextureFunctor() {}; + virtual ~ClusterProminenceTextureFunctor() {}; + typedef MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -60,14 +60,14 @@ public: double out = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = this->GetHisto()[r][s]*areaInv; - double sumPixel = (static_cast<double>(s)+0.5)*this->GetNeighBinLength() + (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - out += vcl_pow( sumPixel - 2*mean, 4) * p; - } + double p = this->GetHisto()[r][s]*areaInv; + double sumPixel = (static_cast<double>(s)+0.5)*this->GetNeighBinLength() + (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + out += vcl_pow( sumPixel - 2*mean, 4) * p; } + } return out; } diff --git a/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h b/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h old mode 100755 new mode 100644 index a7150427f5..10103875a0 --- a/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h +++ b/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h @@ -41,11 +41,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT ClusterShadeTextureFunctor : -public MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: - ClusterShadeTextureFunctor(){}; - virtual ~ClusterShadeTextureFunctor(){}; + ClusterShadeTextureFunctor() {}; + virtual ~ClusterShadeTextureFunctor() {}; typedef MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -60,14 +60,14 @@ public: for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = this->GetHisto()[r][s]*areaInv; - double sumPixel = (static_cast<double>(s)+0.5)*this->GetNeighBinLength() + (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - out += vcl_pow( sumPixel - 2*mean, 3) * p; - } + double p = this->GetHisto()[r][s]*areaInv; + double sumPixel = (static_cast<double>(s)+0.5)*this->GetNeighBinLength() + (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + out += vcl_pow( sumPixel - 2*mean, 3) * p; } + } return out; } diff --git a/Code/FeatureExtraction/otbContrastTextureFunctor.h b/Code/FeatureExtraction/otbContrastTextureFunctor.h old mode 100755 new mode 100644 index 95e1916360..2c68dd6f3b --- a/Code/FeatureExtraction/otbContrastTextureFunctor.h +++ b/Code/FeatureExtraction/otbContrastTextureFunctor.h @@ -39,12 +39,12 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT ContrastTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - ContrastTextureFunctor(){}; - virtual ~ContrastTextureFunctor(){}; - + ContrastTextureFunctor() {}; + virtual ~ContrastTextureFunctor() {}; + typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -57,22 +57,22 @@ public: // loop over bin neighborhood values for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) + { + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + double nCeilSquare = vcl_pow( nCeil, 2); + for (unsigned r = 0; r<this->GetHisto().size(); r++) { - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - double nCeilSquare = vcl_pow( nCeil, 2); - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - if( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - double p = static_cast<double>(this->GetHisto()[r][s])*areaInv; - out += nCeilSquare * p; - } - } - } + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + if ( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + double p = static_cast<double>(this->GetHisto()[r][s])*areaInv; + out += nCeilSquare * p; + } + } } + } return out; } diff --git a/Code/FeatureExtraction/otbCorrelationTextureFunctor.h b/Code/FeatureExtraction/otbCorrelationTextureFunctor.h old mode 100755 new mode 100644 index 9e7c7e469f..78fb64b045 --- a/Code/FeatureExtraction/otbCorrelationTextureFunctor.h +++ b/Code/FeatureExtraction/otbCorrelationTextureFunctor.h @@ -43,11 +43,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT CorrelationTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - CorrelationTextureFunctor(){}; - virtual ~CorrelationTextureFunctor(){}; + CorrelationTextureFunctor() {}; + virtual ~CorrelationTextureFunctor() {}; typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -60,14 +60,14 @@ public: double out = 0.; double sumProb = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = static_cast<double>(this->GetHisto()[r][s])*areaInv; - sumProb += p; - double pixProd = ( (static_cast<double>(r)+0.5)*this->GetOffsetBinLength() ) * ( (static_cast<double>(s)+0.5)*this->GetNeighBinLength() ); - out += pixProd * p; - } + double p = static_cast<double>(this->GetHisto()[r][s])*areaInv; + sumProb += p; + double pixProd = ( (static_cast<double>(r)+0.5)*this->GetOffsetBinLength() ) * ( (static_cast<double>(s)+0.5)*this->GetNeighBinLength() ); + out += pixProd * p; + } } double meanPOff = sumProb/static_cast<double>(this->GetHisto().size()); @@ -76,34 +76,34 @@ public: // Standard deviation of p for offset region double stdPOff = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + double sumTemp = 0.; + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - double sumTemp = 0.; - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - sumTemp += this->GetHisto()[r][s]*areaInv; - } - stdPOff += vcl_pow( (meanPOff-sumTemp), 2); + sumTemp += this->GetHisto()[r][s]*areaInv; } + stdPOff += vcl_pow( (meanPOff-sumTemp), 2); + } stdPOff /= this->GetHisto().size(); stdPOff = vcl_sqrt(stdPOff); // Standard deviation of p for neighborhood region double stdPNeigh = 0.; for (unsigned r = 0; r<this->GetHisto()[0].size(); r++) + { + double sumTemp = 0.; + for (unsigned s = 0; s<this->GetHisto().size(); s++) { - double sumTemp = 0.; - for (unsigned s = 0; s<this->GetHisto().size(); s++) - { - sumTemp += this->GetHisto()[s][r]*areaInv; - } - stdPNeigh += vcl_pow( (meanPNeigh-sumTemp), 2); + sumTemp += this->GetHisto()[s][r]*areaInv; } + stdPNeigh += vcl_pow( (meanPNeigh-sumTemp), 2); + } stdPNeigh /= this->GetHisto()[0].size(); stdPNeigh = vcl_sqrt(stdPNeigh); - if(stdPOff*stdPNeigh != 0) - out = (out - meanPOff*meanPNeigh) / (stdPOff*stdPNeigh); + if (stdPOff*stdPNeigh != 0) + out = (out - meanPOff*meanPNeigh) / (stdPOff*stdPNeigh); return out; } diff --git a/Code/FeatureExtraction/otbDifferenceEntropyTextureFunctor.h b/Code/FeatureExtraction/otbDifferenceEntropyTextureFunctor.h old mode 100755 new mode 100644 index 712f9c8011..56cfbb0495 --- a/Code/FeatureExtraction/otbDifferenceEntropyTextureFunctor.h +++ b/Code/FeatureExtraction/otbDifferenceEntropyTextureFunctor.h @@ -40,11 +40,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT DifferenceEntropyTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - DifferenceEntropyTextureFunctor(){}; - virtual ~DifferenceEntropyTextureFunctor(){}; + DifferenceEntropyTextureFunctor() {}; + virtual ~DifferenceEntropyTextureFunctor() {}; typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -58,25 +58,25 @@ public: // loop over bin neighborhood values for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) + { + double Px_y = 0.; + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + for (unsigned r = 0; r<this->GetHisto().size(); r++) { - double Px_y = 0.; - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - if( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - } - } - if(Px_y != 0.) - out += Px_y * vcl_log(Px_y); + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + if ( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + } } + if (Px_y != 0.) + out += Px_y * vcl_log(Px_y); + } - if(out != 0) + if (out != 0) out = -out; return out; diff --git a/Code/FeatureExtraction/otbDifferenceVarianceTextureFunctor.h b/Code/FeatureExtraction/otbDifferenceVarianceTextureFunctor.h old mode 100755 new mode 100644 index e8aa1ae348..7b0ec74a60 --- a/Code/FeatureExtraction/otbDifferenceVarianceTextureFunctor.h +++ b/Code/FeatureExtraction/otbDifferenceVarianceTextureFunctor.h @@ -39,11 +39,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT DifferenceVarianceTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - DifferenceVarianceTextureFunctor(){}; - virtual ~DifferenceVarianceTextureFunctor(){}; + DifferenceVarianceTextureFunctor() {}; + virtual ~DifferenceVarianceTextureFunctor() {}; typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -57,41 +57,41 @@ public: double MeanPx_y = 0.; // Computes mean Px_y for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) + { + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + for (unsigned r = 0; r<this->GetHisto().size(); r++) { - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - if( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - MeanPx_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - } - } + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + if ( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + MeanPx_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + } } + } MeanPx_y /= static_cast<double>(this->GetHisto()[0].size()); // Computes variance double varPx_y = 0.; for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) + { + double Px_y = 0.; + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + for (unsigned r = 0; r<this->GetHisto().size(); r++) { - double Px_y = 0.; - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - if( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - } - } - varPx_y += vcl_pow((Px_y - MeanPx_y), 2); + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + if ( vcl_abs((static_cast<double>(s)+0.5)*this->GetNeighBinLength() - rVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + } } + varPx_y += vcl_pow((Px_y - MeanPx_y), 2); + } return varPx_y/this->GetHisto()[0].size(); } diff --git a/Code/FeatureExtraction/otbEnergyTextureFunctor.h b/Code/FeatureExtraction/otbEnergyTextureFunctor.h old mode 100755 new mode 100644 index 31467044b4..5d7a99e79a --- a/Code/FeatureExtraction/otbEnergyTextureFunctor.h +++ b/Code/FeatureExtraction/otbEnergyTextureFunctor.h @@ -39,11 +39,11 @@ namespace Functor */ template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT EnergyTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - EnergyTextureFunctor(){}; - virtual ~EnergyTextureFunctor(){}; + EnergyTextureFunctor() {}; + virtual ~EnergyTextureFunctor() {}; typedef TScalarInputPixelType InputScalarType; typedef TScalarOutputPixelType OutputScalarType; @@ -51,7 +51,7 @@ public: typedef typename Superclass::OffsetType OffsetType; typedef typename Superclass::RadiusType RadiusType; typedef typename Superclass::NeighborhoodType NeighborhoodType; - + double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) { @@ -71,18 +71,18 @@ public: offsetOff = offsetOffInit; for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) + { + offsetOff[0]++; + offsetOff[1] = offsetOffInit[1]; + offset[0] = l; + for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) { - offsetOff[0]++; - offsetOff[1] = offsetOffInit[1]; - offset[0] = l; - for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) - { - offsetOff[1]++; - offset[1] = k; - norm = vcl_pow(static_cast<double>( ( neigh[offset] - neighOff[neighOff.GetCenterNeighborhoodIndex()] ) ), 2); - temp += norm; - } + offsetOff[1]++; + offset[1] = k; + norm = vcl_pow(static_cast<double>( ( neigh[offset] - neighOff[neighOff.GetCenterNeighborhoodIndex()] ) ), 2); + temp += norm; } + } temp /= area; return vcl_pow(temp, 2); } diff --git a/Code/FeatureExtraction/otbEntropyTextureFunctor.h b/Code/FeatureExtraction/otbEntropyTextureFunctor.h old mode 100755 new mode 100644 index b416320202..d0588221a6 --- a/Code/FeatureExtraction/otbEntropyTextureFunctor.h +++ b/Code/FeatureExtraction/otbEntropyTextureFunctor.h @@ -39,11 +39,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT EntropyTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - EntropyTextureFunctor(){}; - virtual ~EntropyTextureFunctor(){}; + EntropyTextureFunctor() {}; + virtual ~EntropyTextureFunctor() {}; typedef TScalarInputPixelType InputScalarType; typedef TScalarOutputPixelType OutputScalarType; @@ -65,19 +65,19 @@ public: double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); double areaInv = 1/area; double out = 0.; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; - if (p != 0) - out += (p * vcl_log(p)); - } - } - if (out != 0.) - out = -(out); + for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; + if (p != 0) + out += (p * vcl_log(p)); + } + } + if (out != 0.) + out = -(out); - return out; + return out; } }; diff --git a/Code/FeatureExtraction/otbExtractSegmentsImageFilter.txx b/Code/FeatureExtraction/otbExtractSegmentsImageFilter.txx index c3d072aa0c..2851f02cb6 100644 --- a/Code/FeatureExtraction/otbExtractSegmentsImageFilter.txx +++ b/Code/FeatureExtraction/otbExtractSegmentsImageFilter.txx @@ -216,7 +216,7 @@ void ExtractSegmentsImageFilter<TInputImage, TOutputImage> ::GenerateData() { - + m_PixelSuppression->SetInputImage( this->GetInputImage() ); m_PixelSuppression->SetInputImageDirection( this->GetInputImageDirection() ); diff --git a/Code/FeatureExtraction/otbInformationMeasureOfCorrelation1TextureFunctor.h b/Code/FeatureExtraction/otbInformationMeasureOfCorrelation1TextureFunctor.h old mode 100755 new mode 100644 index 2c7a350a44..dcce2b20ce --- a/Code/FeatureExtraction/otbInformationMeasureOfCorrelation1TextureFunctor.h +++ b/Code/FeatureExtraction/otbInformationMeasureOfCorrelation1TextureFunctor.h @@ -42,12 +42,12 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT InformationMeasureOfCorrelation1TextureFunctor : -public EntropyTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public EntropyTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: - InformationMeasureOfCorrelation1TextureFunctor(){}; - virtual ~InformationMeasureOfCorrelation1TextureFunctor(){}; - + InformationMeasureOfCorrelation1TextureFunctor() {}; + virtual ~InformationMeasureOfCorrelation1TextureFunctor() {}; + typedef EntropyTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -65,16 +65,16 @@ public: // Computes HX double HX = 0.; for (unsigned r = 0; r<this->GetHisto()[0].size(); r++) + { + double sumTemp = 0.; + for (unsigned s = 0; s<this->GetHisto().size(); s++) { - double sumTemp = 0.; - for (unsigned s = 0; s<this->GetHisto().size(); s++) - { - sumTemp += this->GetHisto()[s][r]*areaInv; - } - PxVector.push_back( sumTemp ); - if(sumTemp != 0. ) - HX += sumTemp * vcl_log( sumTemp ); + sumTemp += this->GetHisto()[s][r]*areaInv; } + PxVector.push_back( sumTemp ); + if (sumTemp != 0. ) + HX += sumTemp * vcl_log( sumTemp ); + } if ( HX != 0. ) HX = -HX; @@ -82,16 +82,16 @@ public: // Computes HY double HY = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + double sumTemp = 0.; + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - double sumTemp = 0.; - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - sumTemp += this->GetHisto()[r][s]*areaInv; - } - PyVector.push_back( sumTemp ); - if(sumTemp != 0. ) - HY += sumTemp * vcl_log( sumTemp ); + sumTemp += this->GetHisto()[r][s]*areaInv; } + PyVector.push_back( sumTemp ); + if (sumTemp != 0. ) + HY += sumTemp * vcl_log( sumTemp ); + } if ( HY != 0. ) HY = -HY; @@ -99,21 +99,21 @@ public: // Computes HXY1 double HXY1 = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - if( PyVector[r]*PxVector[s] != 0. ) - { - double p = this->GetHisto()[r][s]*areaInv; - HXY1 += p * vcl_log( PyVector[r]*PxVector[s] ); - } - - } + if ( PyVector[r]*PxVector[s] != 0. ) + { + double p = this->GetHisto()[r][s]*areaInv; + HXY1 += p * vcl_log( PyVector[r]*PxVector[s] ); + } + } + } if ( HXY1 != 0. ) HXY1 = -HXY1; - if( std::max(HX, HY) != 0.) + if ( std::max(HX, HY) != 0.) out = (HXY-HXY1) / std::max(HX, HY); return out; diff --git a/Code/FeatureExtraction/otbInformationMeasureOfCorrelation2TextureFunctor.h b/Code/FeatureExtraction/otbInformationMeasureOfCorrelation2TextureFunctor.h old mode 100755 new mode 100644 index df64f8bedd..7599736eff --- a/Code/FeatureExtraction/otbInformationMeasureOfCorrelation2TextureFunctor.h +++ b/Code/FeatureExtraction/otbInformationMeasureOfCorrelation2TextureFunctor.h @@ -42,11 +42,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT InformationMeasureOfCorrelation2TextureFunctor : -public EntropyTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public EntropyTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: - InformationMeasureOfCorrelation2TextureFunctor(){}; - virtual ~InformationMeasureOfCorrelation2TextureFunctor(){}; + InformationMeasureOfCorrelation2TextureFunctor() {}; + virtual ~InformationMeasureOfCorrelation2TextureFunctor() {}; typedef EntropyTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -64,40 +64,40 @@ public: // Computes HX for (unsigned r = 0; r<this->GetHisto()[0].size(); r++) + { + double sumTemp = 0.; + for (unsigned s = 0; s<this->GetHisto().size(); s++) { - double sumTemp = 0.; - for (unsigned s = 0; s<this->GetHisto().size(); s++) - { - sumTemp += this->GetHisto()[s][r]*areaInv; - } - PxVector.push_back( sumTemp ); + sumTemp += this->GetHisto()[s][r]*areaInv; } + PxVector.push_back( sumTemp ); + } // Computes HY for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + double sumTemp = 0.; + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - double sumTemp = 0.; - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - sumTemp += this->GetHisto()[r][s]*areaInv; - } - PyVector.push_back( sumTemp ); + sumTemp += this->GetHisto()[r][s]*areaInv; } + PyVector.push_back( sumTemp ); + } // Computes HXY2 double HXY2 = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double PxPy = PyVector[r]*PxVector[s]; - if( PxPy != 0. ) - { - HXY2 += PxPy * vcl_log( PxPy ); - } - - } + double PxPy = PyVector[r]*PxVector[s]; + if ( PxPy != 0. ) + { + HXY2 += PxPy * vcl_log( PxPy ); + } + } + } if ( HXY2 != 0. ) HXY2 = -HXY2; diff --git a/Code/FeatureExtraction/otbInverseDifferenceMomentTextureFunctor.h b/Code/FeatureExtraction/otbInverseDifferenceMomentTextureFunctor.h old mode 100755 new mode 100644 index 910c52c72d..8be5eef7d4 --- a/Code/FeatureExtraction/otbInverseDifferenceMomentTextureFunctor.h +++ b/Code/FeatureExtraction/otbInverseDifferenceMomentTextureFunctor.h @@ -39,32 +39,32 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT InverseDifferenceMomentTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - InverseDifferenceMomentTextureFunctor(){}; - virtual ~InverseDifferenceMomentTextureFunctor(){}; + InverseDifferenceMomentTextureFunctor() {}; + virtual ~InverseDifferenceMomentTextureFunctor() {}; typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; - - virtual double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) + + virtual double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) { this->ComputeJointHistogram(neigh, neighOff); double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); double areaInv = 1/area; double out = 0.; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; - double dist = vcl_pow( ( (static_cast<double>(r)+0.5)*this->GetOffsetBinLength())-((static_cast<double>(s)+0.5)*this->GetNeighBinLength()), 2); - - out += ((1/(1+dist)) * p); - } - } - return out; + for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; + double dist = vcl_pow( ( (static_cast<double>(r)+0.5)*this->GetOffsetBinLength())-((static_cast<double>(s)+0.5)*this->GetNeighBinLength()), 2); + + out += ((1/(1+dist)) * p); + } + } + return out; } }; @@ -72,7 +72,7 @@ public: - } // namespace Functor +} // namespace Functor } // namespace otb #endif diff --git a/Code/FeatureExtraction/otbLineSegmentDetector.h b/Code/FeatureExtraction/otbLineSegmentDetector.h index e17c88a72b..ff7225ee9a 100644 --- a/Code/FeatureExtraction/otbLineSegmentDetector.h +++ b/Code/FeatureExtraction/otbLineSegmentDetector.h @@ -34,50 +34,50 @@ namespace otb { namespace Functor +{ +/** \class MagnitudeFunctor + * \brief This functor computes the magnitude of a covariant vector. + */ +template <class TInputPixel,class TOutputPixel> +class MagnitudeFunctor +{ +public: + + inline TOutputPixel operator()(const TInputPixel& input) + { + return static_cast<TOutputPixel>(2*vcl_sqrt(input[0]*input[0] + input[1]*input[1] )); + } +}; + +/** \class OrientationFunctor + * \brief This functor computes the orientation of a cavariant vector<br> + * Orientation values lies between 0 and 2*Pi. + */ +template <class TInputPixel,class TOutputPixel> +class OrientationFunctor +{ +public: + + inline TOutputPixel operator()(const TInputPixel& input) { - /** \class MagnitudeFunctor - * \brief This functor computes the magnitude of a covariant vector. - */ - template <class TInputPixel,class TOutputPixel> - class MagnitudeFunctor - { - public: - - inline TOutputPixel operator()(const TInputPixel& input) - { - return static_cast<TOutputPixel>(2*vcl_sqrt(input[0]*input[0] + input[1]*input[1] )); - } - }; - - /** \class OrientationFunctor - * \brief This functor computes the orientation of a cavariant vector<br> - * Orientation values lies between 0 and 2*Pi. - */ - template <class TInputPixel,class TOutputPixel> - class OrientationFunctor - { - public: - - inline TOutputPixel operator()(const TInputPixel& input) - { - TOutputPixel resp = static_cast<TOutputPixel>(vcl_atan2(input[0],-input[1])); - - if (resp< itk::NumericTraits<TOutputPixel>::Zero) - { - resp = -resp; - } - - return resp; - } - }; - }// end namespace Functor + TOutputPixel resp = static_cast<TOutputPixel>(vcl_atan2(input[0],-input[1])); + + if (resp< itk::NumericTraits<TOutputPixel>::Zero) + { + resp = -resp; + } + + return resp; + } +}; +}// end namespace Functor /** \class LineSegmentDetector - * \brief this class implement a fast line detector with false detection control using + * \brief this class implement a fast line detector with false detection control using * the a contrario method - * - * See Publication : " LSD: A line segment detector ", R. Grompone, J.Jackubowicz, J-M.Morel, G.Randall - * + * + * See Publication : " LSD: A line segment detector ", R. Grompone, J.Jackubowicz, J-M.Morel, G.Randall + * */ template <class TInputImage,class TPrecision = double> @@ -85,16 +85,16 @@ class ITK_EXPORT LineSegmentDetector : public otb::ImageToLineSpatialObjectListFilter< TInputImage > { public: - + /** typedef for the classes standards. */ typedef LineSegmentDetector Self; typedef ImageToLineSpatialObjectListFilter< TInputImage> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for management of the object factory. */ itkNewMacro(Self); - + /** Return the name of the class. */ itkTypeMacro(LineSegmentDetector,ImageToLineSpatialObjectListFilter ); @@ -110,27 +110,27 @@ public: typedef LineSpatialObjectListType::LineType LineSpatialObjectType; typedef LineSpatialObjectType::PointListType PointListType; typedef LineSpatialObjectType::LinePointType PointType; - + /** Definition of temporary image ised to store LABELS*/ typedef Image<TPrecision ,2> OutputImageType; typedef typename OutputImageType::PixelType OutputPixelType; typedef typename OutputImageType::IndexType OutputIndexType; typedef typename OutputImageType::SizeType OutputSizeType; - + /** Histogram to store the coordinate of ordered pixels*/ typedef std::vector<OutputIndexType> IndexVectorType; typedef typename IndexVectorType::iterator IndexVectorIteratorType; typedef std::vector<IndexVectorType > CoordinateHistogramType; typedef typename CoordinateHistogramType::iterator CoordinateHistogramIteratorType; - + /** typedef structure to store REGION*/ typedef std::vector<IndexVectorType> VectorOfIndexVectorType; typedef std::vector<float> DirectionVectorType; - typedef typename DirectionVectorType::iterator DirectionVectorIteratorType; + typedef typename DirectionVectorType::iterator DirectionVectorIteratorType; - /** */ + /** */ typedef itk::GradientRecursiveGaussianImageFilter<OutputImageType > GradientFilterType; //typedef itk::GradientImageFilter<InputImageType > GradientFilterType; typedef typename GradientFilterType::Pointer GradientFilterPointerType; @@ -142,7 +142,7 @@ public: typedef typename MagnitudeFilterType::Pointer MagnitudeFilterPointerType; typedef typename MagnitudeFilterType::OutputImageType::PixelType MagnitudePixelType; typedef typename MagnitudeFilterType::OutputImageType MagnitudeImageType; - + typedef itk::UnaryFunctorImageFilter<GradientOutputImageType,OutputImageType, Functor::OrientationFunctor<typename GradientOutputImageType::PixelType,TPrecision> > OrientationFilterType; typedef typename OrientationFilterType::Pointer OrientationFilterPointerType; @@ -152,12 +152,12 @@ public: /** Create an image to store the label USED(1) or notUsed (0)*/ typedef otb::Image<unsigned char, 2> LabelImageType; typedef typename LabelImageType::Pointer LabelImagePointerType; - + /** Vector to store the rectangle characteization center, width, orientation ,( begin ,end ) of the central line*/ typedef std::vector<double> RectangleType; typedef typename RectangleType::iterator RectangleIteratorType; typedef std::vector< RectangleType> RectangleListType; - typedef typename RectangleListType::iterator RectangleListTypeIterator; + typedef typename RectangleListType::iterator RectangleListTypeIterator; protected: @@ -166,7 +166,7 @@ protected: /** Generate Data method*/ virtual void GenerateData(); - + /** Sort the image and store the coordinates in a histogram * this method is used to determine the seeds where to begin the search segments * Points with large gradient modulus are more able to belong to a segment @@ -175,26 +175,26 @@ protected: /** */ virtual void LineSegmentDetection(CoordinateHistogramType * CoordinateHistogram); - + /** */ virtual bool IsUsed(InputIndexType index); - - /** Set Pixel flag to USED*/ + + /** Set Pixel flag to USED*/ virtual void SetPixelToUsed(InputIndexType index); - - + + /** search for a segment which begins from a seed "index "*/ virtual void GrowRegion(InputIndexType index); - + /** Define if two are aligned */ virtual bool IsAligned(double Angle, double regionAngle, double prec); - + /** For each region of the region List it builds a rectangle */ virtual int ComputeRectangles(); - + /** */ virtual void Region2Rect(IndexVectorType region , double angleRegion); - + /** */ virtual double ComputeRegionOrientation(IndexVectorType region , double x, double y , double angleRegion); @@ -209,10 +209,10 @@ protected: /** NFA For a rectangle*/ virtual double NFA(int n, int k, double p, double logNT); - + /** Create a copy of a rectangle*/ virtual void CopyRectangle(RectangleType * rDst , RectangleType *rSrc ); - + /** Rutines from numerical recipes*/ virtual double betacf(double a, double b, double x); @@ -231,7 +231,7 @@ private: DirectionVectorType m_DirectionVector; LabelImagePointerType m_UsedPointImage; RectangleListType m_RectangleList; - + double m_Threshold; double m_Prec; double m_DirectionsAllowed; @@ -240,7 +240,7 @@ private: int m_Length; int m_Width; - + /** Gradient filter */ GradientFilterPointerType m_GradientFilter; @@ -253,9 +253,9 @@ private: /** Output*/ LineSpatialObjectListPointer m_LineList; - - + + }; } // end namespace otb diff --git a/Code/FeatureExtraction/otbLineSegmentDetector.txx b/Code/FeatureExtraction/otbLineSegmentDetector.txx index 960e024397..1eff1473dc 100644 --- a/Code/FeatureExtraction/otbLineSegmentDetector.txx +++ b/Code/FeatureExtraction/otbLineSegmentDetector.txx @@ -76,7 +76,7 @@ LineSegmentDetector<TInputImage,TPrecision > { /** The Output*/ m_LineList = this->GetOutput(); - + /** Allocate memory for the temporary label Image*/ m_UsedPointImage->SetRegions(this->GetInput()->GetRequestedRegion()); m_UsedPointImage->Allocate(); @@ -86,27 +86,27 @@ LineSegmentDetector<TInputImage,TPrecision > typedef itk::CastImageFilter<InputImageType, OutputImageType> castFilerType; typename castFilerType::Pointer castFilter = castFilerType::New(); castFilter->SetInput(this->GetInput()); - + /** Compute the modulus and the orientation gradient image*/ m_GradientFilter->SetInput(castFilter->GetOutput()); m_GradientFilter->SetSigma(1.1); m_MagnitudeFilter->SetInput(m_GradientFilter->GetOutput()); m_OrientationFilter->SetInput(m_GradientFilter->GetOutput()); - + m_MagnitudeFilter->Update(); m_OrientationFilter->Update(); /** Comupute the seed histogram to begin the search*/ CoordinateHistogramType CoordinateHistogram; CoordinateHistogram = this->SortImageByModulusValue(m_MagnitudeFilter->GetOutput()); - + /** Serach the segments on the image by growing a region from a seed */ this->LineSegmentDetection(&CoordinateHistogram); - - /** - * Compute The rectangles + + /** + * Compute The rectangles * Out : - a List of rectangles : m_RectangleList - * - A Line List m_LineList + * - A Line List m_LineList */ this->ComputeRectangles(); @@ -114,7 +114,7 @@ LineSegmentDetector<TInputImage,TPrecision > /**************************************************************************************************************/ /** - * + * */ template <class TInputImage, class TPrecision > @@ -129,61 +129,61 @@ LineSegmentDetector<TInputImage,TPrecision > m_Length = SizeInput[1]; m_NumberOfImagePixels = m_Length * m_Width; - /** - * Compute the minimum region size + /** + * Compute the minimum region size */ double logNT = 5.*(vcl_log10(static_cast<double>(m_Width)) + vcl_log10(static_cast<double>(m_Length)))/2.; double log1_p = vcl_log10(m_DirectionsAllowed); double rapport = logNT/log1_p; m_MinimumRegionSize = -1*static_cast<unsigned int>(rapport); - + /** Definition of the min & the max of an image*/ OutputPixelType min = itk::NumericTraits</*MagnitudePixelType*/TPrecision>::Zero; OutputPixelType max = itk::NumericTraits</*MagnitudePixelType*/TPrecision>::Zero; - + /** Computing the min & max of the image*/ typedef itk::MinimumMaximumImageCalculator<OutputImageType> MinMaxCalculatorFilter; typename MinMaxCalculatorFilter::Pointer minmaxCalculator = MinMaxCalculatorFilter::New(); - + minmaxCalculator->SetImage(modulusImage); minmaxCalculator->ComputeMinimum(); min = minmaxCalculator->GetMinimum(); minmaxCalculator->ComputeMaximum(); max = minmaxCalculator->GetMaximum(); - + /** Compute the threshold on the gradient*/ m_Threshold = 4*m_Threshold /vcl_sin(m_Prec)*((max-min)/255.); // threshold normalized with min & max of the values - /** Computing the length of the bins*/ - unsigned int NbBin = 10; + /** Computing the length of the bins*/ + unsigned int NbBin = 10; double lengthBin = static_cast<double>((max - min))/static_cast<double>(NbBin-1) ; CoordinateHistogramType tempHisto(NbBin); /** Initializing the histogram */ - - itk::ImageRegionIterator<OutputImageType> it(modulusImage, - modulusImage->GetRequestedRegion()); + + itk::ImageRegionIterator<OutputImageType> it(modulusImage, + modulusImage->GetRequestedRegion()); it.GoToBegin(); - while(!it.IsAtEnd()) + while (!it.IsAtEnd()) + { + OutputIndexType index = it.GetIndex(); + if (static_cast<int>(index[0]) > 0 && static_cast<int>(index[0]) < m_Width-1 + && static_cast<int>(index[1]) >0 && static_cast<int>(index[1]) < m_Length-1 ) { - OutputIndexType index = it.GetIndex(); - if(static_cast<int>(index[0]) > 0 && static_cast<int>(index[0]) < m_Width-1 - && static_cast<int>(index[1]) >0 && static_cast<int>(index[1]) < m_Length-1 ) - { - unsigned int bin = static_cast<unsigned int> (it.Value()/lengthBin); - if( it.Value()- m_Threshold >1e-10 ) - tempHisto[NbBin-bin-1].push_back(it.GetIndex()); - } - ++it; + unsigned int bin = static_cast<unsigned int> (it.Value()/lengthBin); + if ( it.Value()- m_Threshold >1e-10 ) + tempHisto[NbBin-bin-1].push_back(it.GetIndex()); } - + ++it; + } + return tempHisto; } /**************************************************************************************************************/ /** - * Method used to search the segments + * Method used to search the segments */ template <class TInputImage, class TPrecision > @@ -191,32 +191,32 @@ void LineSegmentDetector<TInputImage, TPrecision> ::LineSegmentDetection(CoordinateHistogramType *CoordinateHistogram) { - + /** Begin the search of the segments*/ CoordinateHistogramIteratorType ItCoordinateList = CoordinateHistogram->begin(); - while(ItCoordinateList != CoordinateHistogram->end()) + while (ItCoordinateList != CoordinateHistogram->end()) + { + typename IndexVectorType::iterator ItIndexVector = (*ItCoordinateList).begin(); + while (ItIndexVector != (*ItCoordinateList).end()) { - typename IndexVectorType::iterator ItIndexVector = (*ItCoordinateList).begin(); - while(ItIndexVector != (*ItCoordinateList).end()) - { - InputIndexType index = *ItIndexVector; - - /** If the point is not yet computed */ - if(!this->IsUsed(index)) - { - this->GrowRegion(index); - } - ++ItIndexVector; - } - ++ItCoordinateList; + InputIndexType index = *ItIndexVector; + + /** If the point is not yet computed */ + if (!this->IsUsed(index)) + { + this->GrowRegion(index); + } + ++ItIndexVector; } + ++ItCoordinateList; + } } /**************************************************************************************************************/ /** - * Method used to compute rectangles from region + * Method used to compute rectangles from region * Here you can access the NFA for each region */ template <class TInputImage, class TPrecision > @@ -226,52 +226,52 @@ LineSegmentDetector<TInputImage, TPrecision> { /** Check the size of the region list */ unsigned int sizeRegion = m_RegionList.size(); - if(sizeRegion ==0) + if (sizeRegion ==0) return EXIT_FAILURE; - + /** Compute the rectangle*/ CoordinateHistogramIteratorType ItRegion = m_RegionList.begin(); DirectionVectorIteratorType ItDir = m_DirectionVector.begin(); std::cout << " NB DE REGIONS : "<< m_RegionList.size()<< std::endl; - - while(ItRegion != m_RegionList.end() && ItDir !=m_DirectionVector.end() ) - { - this->Region2Rect(*ItRegion, *ItDir ); - ++ItRegion; - ++ItDir; - } + while (ItRegion != m_RegionList.end() && ItDir !=m_DirectionVector.end() ) + { + + this->Region2Rect(*ItRegion, *ItDir ); + ++ItRegion; + ++ItDir; + } /** Improve the rectangles & store the lines*/ RectangleListTypeIterator itRec = m_RectangleList.begin(); - while(itRec != m_RectangleList.end()) + while (itRec != m_RectangleList.end()) + { + double NFA = this->ImproveRectangle(&(*itRec) ); + /** + * Here we start building the OUTPUT :a LineSpatialObjectList. + */ + if (NFA > 0./** eps */) { - double NFA = this->ImproveRectangle(&(*itRec) ); - /** - * Here we start building the OUTPUT :a LineSpatialObjectList. - */ - if(NFA > 0./** eps */) - { - //std::cout << (*itRec)[0] << " " << (*itRec)[1] << " " << (*itRec)[2] << " " << (*itRec)[3]<<std::endl; - PointListType pointList; - PointType point; - - point.SetPosition(static_cast<TPrecision>((*itRec)[0]),static_cast<TPrecision>((*itRec)[1])); - pointList.push_back(point); - point.SetPosition(static_cast<TPrecision>((*itRec)[2]),static_cast<TPrecision>((*itRec)[3])); - pointList.push_back(point); - - typename LineSpatialObjectType::Pointer line = LineSpatialObjectType::New(); - line->SetId(0); - line->SetPoints( pointList ); - line->ComputeBoundingBox(); - m_LineList->push_back(line); - pointList.clear(); - } - - ++itRec; + //std::cout << (*itRec)[0] << " " << (*itRec)[1] << " " << (*itRec)[2] << " " << (*itRec)[3]<<std::endl; + PointListType pointList; + PointType point; + + point.SetPosition(static_cast<TPrecision>((*itRec)[0]),static_cast<TPrecision>((*itRec)[1])); + pointList.push_back(point); + point.SetPosition(static_cast<TPrecision>((*itRec)[2]),static_cast<TPrecision>((*itRec)[3])); + pointList.push_back(point); + + typename LineSpatialObjectType::Pointer line = LineSpatialObjectType::New(); + line->SetId(0); + line->SetPoints( pointList ); + line->ComputeBoundingBox(); + m_LineList->push_back(line); + pointList.clear(); } + ++itRec; + } + return EXIT_SUCCESS; } @@ -287,16 +287,16 @@ LineSegmentDetector<TInputImage, TPrecision> { RectangleIteratorType itSrc = (*rSrc).begin(); - while(itSrc != (*rSrc).end()) - { - (*rDst).push_back(*itSrc); - ++itSrc; - } + while (itSrc != (*rSrc).end()) + { + (*rDst).push_back(*itSrc); + ++itSrc; + } } /**************************************************************************************************************/ /** - * Method used to compute improve the NFA of The rectangle by changing + * Method used to compute improve the NFA of The rectangle by changing * the components of the rectangle */ template <class TInputImage, class TPrecision > @@ -311,96 +311,96 @@ LineSegmentDetector<TInputImage, TPrecision> RectangleType r; double NFA = this->ComputeRectNFA(*rec); - - if( NFA > 0. ) return NFA; - + + if ( NFA > 0. ) return NFA; + /*Try to improve the precison of the oriented */ CopyRectangle(&r ,rec ); - for(n=0; n<5; n++) + for (n=0; n<5; n++) + { + r[7] /= 2.0; + r[6] = M_PI * r[7]; // prec = rec[6] + nfa_new = this->ComputeRectNFA(r); + if ( nfa_new > NFA ) { - r[7] /= 2.0; - r[6] = M_PI * r[7]; // prec = rec[6] - nfa_new = this->ComputeRectNFA(r); - if( nfa_new > NFA ) - { - NFA = nfa_new; - CopyRectangle(rec ,&r ); - } + NFA = nfa_new; + CopyRectangle(rec ,&r ); } - if( NFA > 0. ) return NFA; - + } + if ( NFA > 0. ) return NFA; + /*Try to improve the width of the rectangle*/ CopyRectangle(&r ,rec ); - for(n=0; n<5; n++) + for (n=0; n<5; n++) + { + r[4] -= delta; //r[4] is stored as the width + nfa_new = this->ComputeRectNFA(r); + if ( nfa_new > NFA ) { - r[4] -= delta; //r[4] is stored as the width - nfa_new = this->ComputeRectNFA(r); - if( nfa_new > NFA ) - { - NFA = nfa_new; - CopyRectangle(rec ,&r ); - } + NFA = nfa_new; + CopyRectangle(rec ,&r ); } - if( NFA > 0. ) return NFA; - + } + if ( NFA > 0. ) return NFA; + /*Try to improve the extremity of the segments*/ CopyRectangle(&r ,rec ); - for(n=0; n<5; n++) + for (n=0; n<5; n++) + { + if ( (r[4] - delta) >= 0.5 ) { - if( (r[4] - delta) >= 0.5 ) - { - r[0] += -vcl_sin(r[5]) * delta_2; - r[1] += vcl_cos(r[5])* delta_2; - r[2] += -vcl_sin(r[5])* delta_2; - r[3] += vcl_cos(r[5])* delta_2; - r[4] -= delta; - - nfa_new = this->ComputeRectNFA(r); - if( nfa_new > NFA ) - { - NFA = nfa_new; - CopyRectangle(rec ,&r ); - } - } + r[0] += -vcl_sin(r[5]) * delta_2; + r[1] += vcl_cos(r[5])* delta_2; + r[2] += -vcl_sin(r[5])* delta_2; + r[3] += vcl_cos(r[5])* delta_2; + r[4] -= delta; + + nfa_new = this->ComputeRectNFA(r); + if ( nfa_new > NFA ) + { + NFA = nfa_new; + CopyRectangle(rec ,&r ); + } } - if( NFA > 0. ) return NFA; - + } + if ( NFA > 0. ) return NFA; + CopyRectangle(&r ,rec ); - for(n=0; n<5; n++) + for (n=0; n<5; n++) + { + if ( (r[4] - delta) >= 0.5 ) { - if( (r[4] - delta) >= 0.5 ) - { - r[0] -= -vcl_sin(r[5]) * delta_2; - r[1] -= vcl_cos(r[5])* delta_2; - r[2] -= -vcl_sin(r[5])* delta_2; - r[3] -= vcl_cos(r[5])* delta_2; - r[4] -= delta; - - nfa_new = this->ComputeRectNFA(r); - if( nfa_new > NFA ) - { - NFA = nfa_new; - CopyRectangle(rec ,&r ); - } - } + r[0] -= -vcl_sin(r[5]) * delta_2; + r[1] -= vcl_cos(r[5])* delta_2; + r[2] -= -vcl_sin(r[5])* delta_2; + r[3] -= vcl_cos(r[5])* delta_2; + r[4] -= delta; + + nfa_new = this->ComputeRectNFA(r); + if ( nfa_new > NFA ) + { + NFA = nfa_new; + CopyRectangle(rec ,&r ); + } } - if( NFA > 0. ) return NFA; - + } + if ( NFA > 0. ) return NFA; + /*Try to improve the precision again */ CopyRectangle(&r ,rec ); - for(n=0; n<5; n++) + for (n=0; n<5; n++) + { + r[7] /= 2.0; + r[6] = M_PI * r[7]; // prec = rec[] + nfa_new = this->ComputeRectNFA(r); + if ( nfa_new > NFA ) { - r[7] /= 2.0; - r[6] = M_PI * r[7]; // prec = rec[] - nfa_new = this->ComputeRectNFA(r); - if( nfa_new > NFA ) - { - NFA = nfa_new; - CopyRectangle(rec ,&r ); - } + NFA = nfa_new; + CopyRectangle(rec ,&r ); } - if( NFA > 0. ) return NFA; - + } + if ( NFA > 0. ) return NFA; + return NFA; } @@ -412,20 +412,20 @@ LineSegmentDetector<TInputImage, TPrecision> template <class TInputImage, class TPrecision > bool LineSegmentDetector<TInputImage, TPrecision> -::IsUsed(InputIndexType index) +::IsUsed(InputIndexType index) { bool isUsed = false; - + typedef itk::NeighborhoodIterator<LabelImageType> NeighborhoodLabelIteratorType; typename NeighborhoodLabelIteratorType::SizeType radiusLabel; radiusLabel.Fill(0); NeighborhoodLabelIteratorType itLabel(radiusLabel,m_UsedPointImage, - m_UsedPointImage->GetRequestedRegion()); - + m_UsedPointImage->GetRequestedRegion()); + itLabel.SetLocation(index); - if(*(itLabel.GetCenterValue()) == 1) + if (*(itLabel.GetCenterValue()) == 1) isUsed = true; - + return isUsed; } @@ -437,85 +437,85 @@ LineSegmentDetector<TInputImage, TPrecision> template <class TInputImage, class TPrecision > void LineSegmentDetector<TInputImage, TPrecision> -::SetPixelToUsed(InputIndexType index) +::SetPixelToUsed(InputIndexType index) { typedef itk::NeighborhoodIterator<LabelImageType> NeighborhoodLabelIteratorType; typename NeighborhoodLabelIteratorType::SizeType radiusLabel; radiusLabel.Fill(0); NeighborhoodLabelIteratorType itLabel(radiusLabel,m_UsedPointImage, - m_UsedPointImage->GetRequestedRegion()); + m_UsedPointImage->GetRequestedRegion()); itLabel.SetLocation(index); itLabel.SetCenterPixel(1); // 1 : Set the point status to : Used Point } /**************************************************************************************************************/ /** - * Method GrowRegion : From a seed grow the region to find a connected region with the same orientation + * Method GrowRegion : From a seed grow the region to find a connected region with the same orientation * within a precision (m_Prec) */ template <class TInputImage, class TPrecision > void LineSegmentDetector<TInputImage, TPrecision> -::GrowRegion(InputIndexType index ) +::GrowRegion(InputIndexType index ) { /** Add the point to the used list point*/ this->SetPixelToUsed(index); - + /** Neighborhooding */ typedef itk::ConstNeighborhoodIterator<OutputImageType> NeighborhoodIteratorType; typename NeighborhoodIteratorType::SizeType radius; radius.Fill(1); NeighborhoodIteratorType itNeigh(radius,m_MagnitudeFilter->GetOutput(), - m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); + m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); NeighborhoodIteratorType itNeighDir(radius,m_OrientationFilter->GetOutput() , - m_OrientationFilter->GetOutput()->GetRequestedRegion()); - + m_OrientationFilter->GetOutput()->GetRequestedRegion()); + /** Vector where to store the point belonging to the current region*/ unsigned int neighSize = itNeigh.GetSize()[0]*itNeigh.GetSize()[1]; IndexVectorType reg; /** Angle of the region*/ double regionAngle = 0; - + /** Add the first point to the region */ reg.push_back(index); double sumX = 0.; double sumY = 0.; - - /** - * Loop for searching regions + + /** + * Loop for searching regions */ for (unsigned int cpt = 0; cpt < reg.size() ; cpt++ ) + { + itNeigh.SetLocation(reg[cpt]); + itNeighDir.SetLocation(reg[cpt]); + sumX += vcl_cos(*(itNeighDir.GetCenterValue())); + sumY += vcl_sin(*(itNeighDir.GetCenterValue())); + regionAngle = vcl_atan2(sumY,sumX); + + unsigned int s = 0; + while (s < neighSize ) { - itNeigh.SetLocation(reg[cpt]); - itNeighDir.SetLocation(reg[cpt]); - sumX += vcl_cos(*(itNeighDir.GetCenterValue())); - sumY += vcl_sin(*(itNeighDir.GetCenterValue())); - regionAngle = vcl_atan2(sumY,sumX); - - unsigned int s = 0; - while(s < neighSize ) - { - InputIndexType NeighIndex = itNeigh.GetIndex(s); - double angleComp = itNeighDir.GetPixel(s); - - if( !this->IsUsed(NeighIndex) && this->IsAligned(angleComp, regionAngle, m_Prec) ) - { - if(this->GetInput()->GetRequestedRegion().IsInside(NeighIndex)) /** Check if the index is inside the image*/ - { - this->SetPixelToUsed(NeighIndex); - reg.push_back(NeighIndex); - } - } - s++; - } - }/** End Searching loop*/ - + InputIndexType NeighIndex = itNeigh.GetIndex(s); + double angleComp = itNeighDir.GetPixel(s); + + if ( !this->IsUsed(NeighIndex) && this->IsAligned(angleComp, regionAngle, m_Prec) ) + { + if (this->GetInput()->GetRequestedRegion().IsInside(NeighIndex)) /** Check if the index is inside the image*/ + { + this->SetPixelToUsed(NeighIndex); + reg.push_back(NeighIndex); + } + } + s++; + } + }/** End Searching loop*/ + /** Store the region*/ - if(reg.size()> m_MinimumRegionSize && reg.size() < static_cast<unsigned int>(m_NumberOfImagePixels/2)) + if (reg.size()> m_MinimumRegionSize && reg.size() < static_cast<unsigned int>(m_NumberOfImagePixels/2)) { - m_RegionList.push_back(reg); - m_DirectionVector.push_back(regionAngle); + m_RegionList.push_back(reg); + m_DirectionVector.push_back(regionAngle); } } @@ -529,20 +529,20 @@ LineSegmentDetector<TInputImage, TPrecision> ::IsAligned(double Angle, double regionAngle, double prec) { double diff = Angle - regionAngle; - - if( diff < 0.0 ) diff = -diff; - if( diff > 1.5*M_PI ) - { - diff -= 2*M_PI; - if( diff < 0.0 ) diff = -diff; - } + + if ( diff < 0.0 ) diff = -diff; + if ( diff > 1.5*M_PI ) + { + diff -= 2*M_PI; + if ( diff < 0.0 ) diff = -diff; + } return diff < prec; } /**************************************************************************************************************/ /** - * compute the best rectangle possible that + * compute the best rectangle possible that */ template <class TInputImage, class TPrecision > void @@ -550,106 +550,109 @@ LineSegmentDetector<TInputImage, TPrecision> ::Region2Rect(IndexVectorType region , double angleRegion) { /** Local Variables*/ - double weight = 0.,sumWeight = 0.; + double weight = 0.,sumWeight = 0.; double x = 0., y = 0.; double l_min = 0., l_max = 0.,l =0., w=0. , w_min = 0. , w_max =0.; - + /** Neighborhooding again*/ typedef itk::ConstNeighborhoodIterator<OutputImageType> NeighborhoodIteratorType; typename NeighborhoodIteratorType::SizeType radius; radius.Fill(0); NeighborhoodIteratorType itNeigh(radius,m_MagnitudeFilter->GetOutput(), - m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); + m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); /** Computing the center of the rectangle*/ IndexVectorIteratorType it = region.begin(); - while(it != region.end()) - { - itNeigh.SetLocation(*it); - weight = *itNeigh.GetCenterValue(); - x += static_cast<double>((*it)[0])* weight; - y += static_cast<double>((*it)[1])* weight; - sumWeight += weight; - ++it; - } - if(sumWeight < 1e-10) - { - x = 0.; y = 0.; - } + while (it != region.end()) + { + itNeigh.SetLocation(*it); + weight = *itNeigh.GetCenterValue(); + x += static_cast<double>((*it)[0])* weight; + y += static_cast<double>((*it)[1])* weight; + sumWeight += weight; + ++it; + } + if (sumWeight < 1e-10) + { + x = 0.; + y = 0.; + } else - { - x/= sumWeight ; - y/= sumWeight ; - } - + { + x/= sumWeight ; + y/= sumWeight ; + } + /** Compute the orientation of the region*/ - double theta = this->ComputeRegionOrientation(region , x , y , angleRegion); - + double theta = this->ComputeRegionOrientation(region , x , y , angleRegion); + /* Lenght & Width of the rectangle **/ - + typedef std::vector<MagnitudePixelType> MagnitudeVector; unsigned int Diagonal = static_cast< unsigned int>(vnl_math_hypot(m_Length ,m_Width)) + 2; MagnitudeVector sum_l( 2*Diagonal, itk::NumericTraits<MagnitudePixelType>::Zero); MagnitudeVector sum_w( 2*Diagonal, itk::NumericTraits<MagnitudePixelType>::Zero); - + double dx = vcl_cos(theta); double dy = vcl_sin(theta); - + it = region.begin(); - while(it != region.end()) - { - itNeigh.SetLocation(*it); - weight = *itNeigh.GetCenterValue(); - l = ( static_cast<double>((*it)[0]) - x )*dx + ( static_cast<double>((*it)[1]) - y )*dy; - w = -( static_cast<double>((*it)[0]) - x )*dy + ( static_cast<double>((*it)[1]) - y )*dx; - - if(l<l_min) l_min = l; if(l>l_max) l_max = l; - if(w<w_min) w_min = w; if(w>w_max) w_max = w; - - sum_l[static_cast< int>(vcl_floor(l)+0.5)+ Diagonal ] += static_cast<MagnitudePixelType>(weight); - sum_w[static_cast< int>(vcl_floor(w)+0.5)+ Diagonal ] += static_cast<MagnitudePixelType>(weight); - - ++it; - } - + while (it != region.end()) + { + itNeigh.SetLocation(*it); + weight = *itNeigh.GetCenterValue(); + l = ( static_cast<double>((*it)[0]) - x )*dx + ( static_cast<double>((*it)[1]) - y )*dy; + w = -( static_cast<double>((*it)[0]) - x )*dy + ( static_cast<double>((*it)[1]) - y )*dx; + + if (l<l_min) l_min = l; + if (l>l_max) l_max = l; + if (w<w_min) w_min = w; + if (w>w_max) w_max = w; + + sum_l[static_cast< int>(vcl_floor(l)+0.5)+ Diagonal ] += static_cast<MagnitudePixelType>(weight); + sum_w[static_cast< int>(vcl_floor(w)+0.5)+ Diagonal ] += static_cast<MagnitudePixelType>(weight); + + ++it; + } + /** Thresholdinq the width and the length*/ - + double sum_th = 0.01 * sumWeight; /* weight threshold for selecting region */ double s = 0.; int i = 0; - - for( s=0.0,i = static_cast<int>(l_min); s<sum_th && i<=static_cast<int>(l_max) ; i++) + + for ( s=0.0,i = static_cast<int>(l_min); s<sum_th && i<=static_cast<int>(l_max) ; i++) s += sum_l[ Diagonal + i]; - + double lb = (static_cast<double>(i-1) - 0.5 ); - - for(s=0.0,i=static_cast<int>(l_max); s<sum_th && i>=static_cast<int>(l_min); i--) + + for (s=0.0,i=static_cast<int>(l_max); s<sum_th && i>=static_cast<int>(l_min); i--) s += sum_l[ Diagonal + i]; - double lf = (static_cast<double>(i+1) + 0.5 ); + double lf = (static_cast<double>(i+1) + 0.5 ); - for(s=0.0,i=static_cast<int>(w_min); s<sum_th && i<=static_cast<int>(w_max); i++) + for (s=0.0,i=static_cast<int>(w_min); s<sum_th && i<=static_cast<int>(w_max); i++) s += sum_w[ Diagonal + i]; - - double wr = (static_cast<double>(i-1) - 0.5); - for(s=0.0,i=static_cast<int>(w_max); s<sum_th && i>=static_cast<int>(w_min); i--) + double wr = (static_cast<double>(i-1) - 0.5); + + for (s=0.0,i=static_cast<int>(w_max); s<sum_th && i>=static_cast<int>(w_min); i--) s += sum_w[Diagonal + i]; - - double wl = (static_cast<double>(i+1) + 0.5 ); + + double wl = (static_cast<double>(i+1) + 0.5 ); - /** Finally store the rectangle in vector this way : - * vec[0] = x1 + /** Finally store the rectangle in vector this way : + * vec[0] = x1 * vec[1] = y1 - * vec[2] = x2 + * vec[2] = x2 * vec[3] = y2 * vec[4] = width * vec[5] = theta * vec[6] = prec = Pi/8 * vec[7] = p = 1/8 */ - + RectangleType rec(8 ,0.); // Definition of a rectangle : 8 components rec[0] = (x + lb*dx >0)?x + lb*dx:0.; rec[1] = (y + lb*dy >0)?y + lb*dy:0.; @@ -659,8 +662,8 @@ LineSegmentDetector<TInputImage, TPrecision> rec[5] = theta; rec[6] = m_Prec; rec[7] = m_DirectionsAllowed; - - if(rec[4] - 1. <1e-10) rec[4] = 1.; + + if (rec[4] - 1. <1e-10) rec[4] = 1.; m_RectangleList.push_back(rec); } @@ -672,7 +675,7 @@ LineSegmentDetector<TInputImage, TPrecision> template <class TInputImage, class TPrecision > double LineSegmentDetector<TInputImage, TPrecision> -::ComputeRegionOrientation(IndexVectorType region , double x,double y , double angleRegion) +::ComputeRegionOrientation(IndexVectorType region , double x,double y , double angleRegion) { double Ixx = 0.0; @@ -680,29 +683,29 @@ LineSegmentDetector<TInputImage, TPrecision> double Ixy = 0.0; double theta = 0.; double weight = 0.,sum = 0.; - + /** Neighborhooding again*/ typedef itk::ConstNeighborhoodIterator<OutputImageType> NeighborhoodIteratorType; typename NeighborhoodIteratorType::SizeType radius; radius.Fill(0); NeighborhoodIteratorType itNeigh(radius,m_MagnitudeFilter->GetOutput(), - m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); - + m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); + /** Computing the center iof the rectangle*/ IndexVectorIteratorType it = region.begin(); - while(it != region.end()) - { - itNeigh.SetLocation(*it); - weight = *itNeigh.GetCenterValue(); - double Iyy2 = static_cast<double>((*it)[0]) - x; - double Ixx2 = static_cast<double>((*it)[1]) - y; - - Ixx += Ixx2*Ixx2*weight; - Iyy += Iyy2*Iyy2*weight; - Ixy -= Ixx2*Iyy2*weight; - sum += weight; - ++it; - } + while (it != region.end()) + { + itNeigh.SetLocation(*it); + weight = *itNeigh.GetCenterValue(); + double Iyy2 = static_cast<double>((*it)[0]) - x; + double Ixx2 = static_cast<double>((*it)[1]) - y; + + Ixx += Ixx2*Ixx2*weight; + Iyy += Iyy2*Iyy2*weight; + Ixy -= Ixx2*Iyy2*weight; + sum += weight; + ++it; + } /** using te itk Eigen analysis*/ typedef itk::Matrix<double , 2, 2> MatrixType; @@ -713,17 +716,17 @@ LineSegmentDetector<TInputImage, TPrecision> Inertie[0][0] =Iyy; Inertie[0][1] =Ixy; Inertie[1][0] =Ixy; - + typedef itk::SymmetricEigenAnalysis<MatrixType,MatrixEigenType> EigenAnalysisType; EigenAnalysisType eigenFilter(2) ; eigenFilter.ComputeEigenValuesAndVectors(Inertie,eigenMatrix,eigenVector ); theta = vcl_atan2(eigenVector[1][1], -eigenVector[1][0]); - + /* the previous procedure don't cares orientations, so it could be wrong by 180 degrees. here is corrected if necessary */ - if( this->angle_diff(theta,angleRegion) > m_Prec ) theta += M_PI; + if ( this->angle_diff(theta,angleRegion) > m_Prec ) theta += M_PI; return theta; } @@ -733,38 +736,38 @@ LineSegmentDetector<TInputImage, TPrecision> * Compute the difference betwenn 2 angles modulo 2_PI */ template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::angle_diff(double a, double b) { a -= b; - while( a <= -M_PI ) a += 2*M_PI; - while( a > M_PI ) a -= 2*M_PI; - if( a < 0.0 ) a = -a; + while ( a <= -M_PI ) a += 2*M_PI; + while ( a > M_PI ) a -= 2*M_PI; + if ( a < 0.0 ) a = -a; return a; } /**************************************************************************************************************/ /** - * compute the number of false alarm of the rectangle + * compute the number of false alarm of the rectangle */ template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::ComputeRectNFA(RectangleType rec) { int NbAligned = 0; double nfa_val = 0.; - + double dx = vcl_cos(rec[5]); double dy = vcl_sin(rec[5]); double halfWidth = rec[4]/2; - + /** Determine the four corners of the rectangle*/ - /** Remember : - * vec[0] = x1 + /** Remember : + * vec[0] = x1 * vec[1] = y1 - * vec[2] = x2 + * vec[2] = x2 * vec[3] = y2 * vec[4] = width * vec[5] = theta @@ -773,7 +776,7 @@ LineSegmentDetector<TInputImage, TPrecision> */ RectangleType X(4,0.) , Y(4,0.); - + X[0] = rec[0] + dy* halfWidth ; Y[0] = rec[1] - dx* halfWidth ; X[1] = rec[0] - dy* halfWidth ; @@ -784,49 +787,49 @@ LineSegmentDetector<TInputImage, TPrecision> Y[3] = rec[3] + dx* halfWidth ; - /** Compute the NFA of the rectangle + /** Compute the NFA of the rectangle * We Need : The number of : Points in the rec (Area of the rectangle) * Aligned points with theta in the rectangle */ - + /** Compute the number of points aligned */ typedef otb::Polygon<double> PolygonType; PolygonType::Pointer rectangle = PolygonType::New(); /** Fill the rectangle with the points*/ for (int i = 0; i<static_cast<int>(X.size()); i++) - { - OutputIndexType vertex; - vertex[0] = static_cast<long int>(X[i]); - vertex[1] = static_cast<long int>(Y[i]); - rectangle->AddVertex(vertex); - } - + { + OutputIndexType vertex; + vertex[0] = static_cast<long int>(X[i]); + vertex[1] = static_cast<long int>(Y[i]); + rectangle->AddVertex(vertex); + } + /** Get The Bounding Region*/ OutputImageDirRegionType region = rectangle->GetBoundingRegion(); - + itk::ImageRegionIterator<OutputImageDirType> it(m_OrientationFilter->GetOutput(), region/*m_OrientationFilter->GetOutput()->GetRequestedRegion()*/); it.GoToBegin(); - + int pts = 0; - - while(!it.IsAtEnd()) + + while (!it.IsAtEnd()) + { + if ( rectangle->IsInside( it.GetIndex()) && m_OrientationFilter->GetOutput()->GetRequestedRegion().IsInside( it.GetIndex()) ) { - if( rectangle->IsInside( it.GetIndex()) && m_OrientationFilter->GetOutput()->GetRequestedRegion().IsInside( it.GetIndex()) ) - { - pts++; - - if(this->IsAligned(it.Get(), rec[5] /*theta*/ ,rec[6] /*Prec*/)) - NbAligned++; - } - ++it; + pts++; + + if (this->IsAligned(it.Get(), rec[5] /*theta*/ ,rec[6] /*Prec*/)) + NbAligned++; } - + ++it; + } + /** Compute the NFA from the rectangle computed below*/ double logNT = 5.*(vcl_log10(static_cast<double>(m_Length)) + vcl_log10(static_cast<double>(m_Width)))/2.; - + nfa_val = NFA(pts,NbAligned ,m_DirectionsAllowed,logNT); - + return nfa_val; } @@ -840,17 +843,17 @@ LineSegmentDetector<TInputImage, TPrecision> logNT - logarithm of Number of Tests */ template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::NFA(int n, int k, double p, double logNT) { double val; - if(k==0) return -logNT; + if (k==0) return -logNT; val = -logNT - log10(betai((double)k,(double)(n-k+1),p)); - if(vnl_math_isinf(val)) /* approximate by the first term of the tail */ + if (vnl_math_isinf(val)) /* approximate by the first term of the tail */ val = -logNT - ( factln(n) - factln(k) - factln(n-k) ) / M_LN10 - (double)k * log10(p) - (double)(n-k) * log10(1.0-p); @@ -881,7 +884,7 @@ LineSegmentDetector<TInputImage, TPrecision> /**************************************************************************************************************/ /**************************************************************************************************************/ template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::betacf(double a, double b, double x) { @@ -896,7 +899,8 @@ LineSegmentDetector<TInputImage, TPrecision> if (fabs(d) < FPMIN) d=FPMIN; d=1.0/d; h=d; - for (m=1;m<=MAXIT;m++) { + for (m=1;m<=MAXIT;m++) + { m2=2*m; aa=m*(b-m)*x/((qam+m2)*(a+m2)); d=1.0+aa*d; @@ -920,14 +924,15 @@ LineSegmentDetector<TInputImage, TPrecision> } template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::gammln(double xx) { double x,y,tmp,ser; static double cof[6]={76.18009172947146,-86.50532032941677, - 24.01409824083091,-1.231739572450155, - 0.1208650973866179e-2,-0.5395239384953e-5}; + 24.01409824083091,-1.231739572450155, + 0.1208650973866179e-2,-0.5395239384953e-5 + }; int j; y=x=xx; @@ -939,7 +944,7 @@ LineSegmentDetector<TInputImage, TPrecision> } template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::betai(double a, double b, double x) { @@ -958,7 +963,7 @@ LineSegmentDetector<TInputImage, TPrecision> template <class TInputImage, class TPrecision > -double +double LineSegmentDetector<TInputImage, TPrecision> ::factln(int n) { diff --git a/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.h b/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.h index 69549c2df4..034d71e91c 100644 --- a/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.h +++ b/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.h @@ -50,7 +50,7 @@ public: /** Run-time type information (and related methods). */ itkTypeMacro(LineSpatialObjectListToRightAnglePointSetFilter,LineSpatialObjectListToPointSetFilter); - + /** Typedef support for ProcessObject*/ typedef itk::ProcessObject ProcessObjectType; @@ -66,7 +66,7 @@ public: */ typedef TImage InputImageType; typedef typename InputImageType::IndexType InputIndexType; - + /** Typedef support for output PointSet*/ typedef TPointSet OutputPointSetType; typedef typename OutputPointSetType::PointType PointType; @@ -76,7 +76,7 @@ public: typedef itk::VariableSizeMatrix<unsigned int> checkMatrixType; /** - * Public Methods : + * Public Methods : * Get the Input Image & Get The input Image */ virtual InputImageType* GetInputImage(); @@ -87,7 +87,7 @@ public: /** Set/Get the thresholds*/ itkGetMacro(ThresholdDistance, float); itkSetMacro(ThresholdDistance, float); - + itkGetMacro(ThresholdAngle, float); itkSetMacro(ThresholdAngle, float); @@ -95,14 +95,14 @@ protected: /** * Without the GenrateOutputInformation below it does not work - * Because the ProcessObject class do a static_cast to allow memory and copy + * Because the ProcessObject class do a static_cast to allow memory and copy * the output (here a pointset). It works fine with images but with pointsets * no size is specified ... * the aim of the GenerateOutputInformation below is to avoid the guilty static_cast - * + * */ - - virtual void GenerateOutputInformation(){}; + + virtual void GenerateOutputInformation() {}; /** * Constructor. @@ -111,7 +111,7 @@ protected: /** * Destructor. */ - virtual ~LineSpatialObjectListToRightAnglePointSetFilter(){}; + virtual ~LineSpatialObjectListToRightAnglePointSetFilter() {}; /** * Standard PrintSelf method. */ @@ -148,7 +148,7 @@ private: float m_ThresholdDistance; float m_ThresholdAngle; - + }; } #ifndef OTB_MANUAL_INSTANTIATION diff --git a/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx b/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx index 6e78364cc1..c55fbcfe15 100644 --- a/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx +++ b/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx @@ -54,9 +54,9 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> const_cast< InputImageType * >( inputImage ) ); } - /** - * Method : Get The Input Image - */ +/** +* Method : Get The Input Image +*/ template <class TImage, class TLinesList , class TPointSet> typename LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> ::InputImageType * @@ -76,7 +76,7 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> ::GenerateData() { unsigned int counterTest = 0, counterCur = 0; - + /** Output*/ m_OutputPointSet = this->GetOutput(); @@ -87,57 +87,57 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> unsigned int numberOfLines = inputLinesList->size(); checkMatrixType segmentsUsedMatrix(numberOfLines,numberOfLines); segmentsUsedMatrix.Fill(0); - + /** Loop to get all the lines in the listLine */ InputLinesListTypeIterator itLinesListTest = inputLinesList->begin(); /** Current tested Line */ - - while(itLinesListTest != inputLinesList->end() ) + + while (itLinesListTest != inputLinesList->end() ) + { + counterCur = 0; + InputLinesListTypeIterator itLinesListCur = inputLinesList->begin(); /** Line tested with with current Line*/ + InputLinesListTypeIterator itLinesListCurEnd = inputLinesList->end(); + + while (itLinesListCur != itLinesListCurEnd ) { - counterCur = 0; - InputLinesListTypeIterator itLinesListCur = inputLinesList->begin(); /** Line tested with with current Line*/ - InputLinesListTypeIterator itLinesListCurEnd = inputLinesList->end(); - - while(itLinesListCur != itLinesListCurEnd ) - { - /** Check If segments are already computed */ - if( segmentsUsedMatrix[counterTest][counterCur]== 0 && segmentsUsedMatrix[counterCur][counterTest] == 0 ) - { - /** Set the segments to USED (== 1)*/ - segmentsUsedMatrix[counterTest][counterCur] = 1; - segmentsUsedMatrix[counterCur][counterTest] = 1; - - /** Compute the distance from CurLine to DstLine*/ - float SegmentDist = this->ComputeDistanceBetweenSegments(*itLinesListTest , *itLinesListCur); - - /** Check if the distance separating the segments is under the threshold*/ - if(SegmentDist < m_ThresholdDistance /* Threshold : 5 Pixels*/) - { - /** Compute the angle formed by the two segments */ - float Angle = this->ComputeAngleFormedBySegments(*itLinesListTest, *itLinesListCur); - - /** Check if the angle is a right one */ - if(vcl_abs(Angle - M_PI/2.) <= m_ThresholdAngle ) - { - /** Right angle coordinate*/ - PointType RightAngleCoordinate; - RightAngleCoordinate = this->ComputeAngleRightCoordinate(*itLinesListTest, *itLinesListCur); - - /** If Right Angle: Add it to the pointSet*/ - this->AddRightAngleToPointSet(RightAngleCoordinate , *itLinesListTest , *itLinesListCur ); - - } - } - } - counterCur++; - ++itLinesListCur; - } - counterTest++; - ++itLinesListTest; + /** Check If segments are already computed */ + if ( segmentsUsedMatrix[counterTest][counterCur]== 0 && segmentsUsedMatrix[counterCur][counterTest] == 0 ) + { + /** Set the segments to USED (== 1)*/ + segmentsUsedMatrix[counterTest][counterCur] = 1; + segmentsUsedMatrix[counterCur][counterTest] = 1; + + /** Compute the distance from CurLine to DstLine*/ + float SegmentDist = this->ComputeDistanceBetweenSegments(*itLinesListTest , *itLinesListCur); + + /** Check if the distance separating the segments is under the threshold*/ + if (SegmentDist < m_ThresholdDistance /* Threshold : 5 Pixels*/) + { + /** Compute the angle formed by the two segments */ + float Angle = this->ComputeAngleFormedBySegments(*itLinesListTest, *itLinesListCur); + + /** Check if the angle is a right one */ + if (vcl_abs(Angle - M_PI/2.) <= m_ThresholdAngle ) + { + /** Right angle coordinate*/ + PointType RightAngleCoordinate; + RightAngleCoordinate = this->ComputeAngleRightCoordinate(*itLinesListTest, *itLinesListCur); + + /** If Right Angle: Add it to the pointSet*/ + this->AddRightAngleToPointSet(RightAngleCoordinate , *itLinesListTest , *itLinesListCur ); + + } + } + } + counterCur++; + ++itLinesListCur; } + counterTest++; + ++itLinesListTest; + } } /** - * Method : ComputeDistanceBetweenSegments + * Method : ComputeDistanceBetweenSegments */ template <class TImage, class TLinesList , class TPointSet> float @@ -145,23 +145,23 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> ::ComputeDistanceBetweenSegments(LineType * lineDst , LineType * lineSrc) { /** Local variable*/ - InputIndexType IndexBeginSrc, IndexEndSrc; - + InputIndexType IndexBeginSrc, IndexEndSrc; + /** Extract Indexes from the Src line for segment distance computation*/ typename LineType::PointListType & pointsList = lineSrc->GetPoints(); typename LineType::PointListType::const_iterator itPoints = pointsList.begin(); - - IndexBeginSrc[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); - IndexBeginSrc[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); + + IndexBeginSrc[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); + IndexBeginSrc[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); ++itPoints; - IndexEndSrc[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); - IndexEndSrc[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); - + IndexEndSrc[0] = static_cast<unsigned int>((*itPoints).GetPosition()[0]); + IndexEndSrc[1] = static_cast<unsigned int>((*itPoints).GetPosition()[1]); + /** Verify if the indexes of the line are inside the region*/ typename InputImageType::SizeType size = this->GetInputImage()->GetRequestedRegion().GetSize(); //unsigned int width = size[0]; //unsigned int length = size[1]; - + // if(IndexBeginSrc[0] > width) IndexBeginSrc[0] = width-1; // if(IndexBeginSrc[1] > length) IndexBeginSrc[1] = length-1; @@ -174,7 +174,7 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> // if(IndexEndSrc[0]<0) IndexEndSrc[0] = 0; // if(IndexEndSrc[1]<0) IndexEndSrc[1] = 0; - + /** Extract Indexes from the Dst line to instantiate the line iterator*/ typename LineType::PointListType &pointsListDst = lineDst->GetPoints(); typename LineType::PointListType::const_iterator itPointsDst = pointsListDst.begin(); @@ -184,48 +184,48 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> ++itPointsDst; float Xq2 = (*itPointsDst).GetPosition()[0]; //xq2 float Yq2 = (*itPointsDst).GetPosition()[1]; //yq2 - + /** Those constants are used in the loop : compute them once * d(P,[Q1Q2]) = |PQ1^PQ2|/|Q1Q2| */ - + float SegmentLength = (Xq1-Xq2)* (Xq1-Xq2) + (Yq1-Yq2) *(Yq1-Yq2); float CrossProduct = Xq1*Yq2 - Xq2*Yq1 ; /** Define a line iterator */ itk::LineIterator<InputImageType> itLine(this->GetInputImage() , IndexBeginSrc , IndexEndSrc); itLine.GoToBegin(); - + float MinDistance = 10000.; - while(!itLine.IsAtEnd()) + while (!itLine.IsAtEnd()) + { + InputIndexType IndexCur = itLine.GetIndex(); + + if (this->GetInputImage()->GetRequestedRegion().IsInside(IndexCur) ) { - InputIndexType IndexCur = itLine.GetIndex(); - - if(this->GetInputImage()->GetRequestedRegion().IsInside(IndexCur) ) - { - float xp = static_cast<float>(itLine.GetIndex()[0]); - float yp = static_cast<float>(itLine.GetIndex()[1]); - float Num = vcl_abs(xp*(Yq1-Yq2) + yp*(Xq2-Xq1) + CrossProduct); - - /** distance from Point P to Segment Q1Q2*/ - float CurDistance = Num/SegmentLength; - - if(CurDistance < MinDistance ) - MinDistance = CurDistance; - - if(MinDistance < 1e-50) //MinDistance supposed to be positive - return 0.; - } - ++itLine; + float xp = static_cast<float>(itLine.GetIndex()[0]); + float yp = static_cast<float>(itLine.GetIndex()[1]); + float Num = vcl_abs(xp*(Yq1-Yq2) + yp*(Xq2-Xq1) + CrossProduct); + + /** distance from Point P to Segment Q1Q2*/ + float CurDistance = Num/SegmentLength; + + if (CurDistance < MinDistance ) + MinDistance = CurDistance; + + if (MinDistance < 1e-50) //MinDistance supposed to be positive + return 0.; } - + ++itLine; + } + return MinDistance; } /** * Method : Compute Angle formed by the two segments - * + * */ template <class TImage, class TLinesList , class TPointSet> float @@ -235,13 +235,13 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> /** ----- */ typename LineType::PointListType & pointsList = lineSrc->GetPoints(); typename LineType::PointListType::const_iterator itPoints = pointsList.begin(); - - float Xp1 = (*itPoints).GetPosition()[0]; - float Yp1 = (*itPoints).GetPosition()[1]; + + float Xp1 = (*itPoints).GetPosition()[0]; + float Yp1 = (*itPoints).GetPosition()[1]; ++itPoints; - float Xp2 = (*itPoints).GetPosition()[0]; - float Yp2 = (*itPoints).GetPosition()[1]; - + float Xp2 = (*itPoints).GetPosition()[0]; + float Yp2 = (*itPoints).GetPosition()[1]; + /** Extract Indexes from the Dst line to instantiate the line iterator*/ typename LineType::PointListType &pointsListDst = lineDst->GetPoints(); typename LineType::PointListType::const_iterator itPointsDst = pointsListDst.begin(); @@ -255,17 +255,17 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> /** Vectors support computation */ float SegmentLengthP = vcl_sqrt( (Xp1-Xp2)* (Xp1-Xp2) + (Yp1-Yp2) *(Yp1-Yp2) ) ; float SegmentLengthQ = vcl_sqrt( (Xq1-Xq2)* (Xq1-Xq2) + (Yq1-Yq2) *(Yq1-Yq2) ) ; - + float X = vcl_abs((Xp1 - Xp2)*(Xq1-Xq2)); float Y = vcl_abs((Yp1 - Yp2)*(Yq1-Yq2)); float angle = vcl_acos( ( X + Y )/( SegmentLengthP * SegmentLengthQ )); //Scalar Product - + return angle; } /** - * Method : ComputeDistanceBetweenSegments + * Method : ComputeDistanceBetweenSegments */ template <class TImage, class TLinesList , class TPointSet> typename LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> @@ -274,21 +274,21 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> ::ComputeAngleRightCoordinate(LineType * lineDst , LineType * lineSrc) { PointType P; - + /** ----- */ typename LineType::PointListType & pointsList = lineSrc->GetPoints(); typename LineType::PointListType::const_iterator itPoints = pointsList.begin(); - - float Xp1 = (*itPoints).GetPosition()[0]; - float Yp1 = (*itPoints).GetPosition()[1]; + + float Xp1 = (*itPoints).GetPosition()[0]; + float Yp1 = (*itPoints).GetPosition()[1]; ++itPoints; - float Xp2 = (*itPoints).GetPosition()[0]; - float Yp2 = (*itPoints).GetPosition()[1]; - + float Xp2 = (*itPoints).GetPosition()[0]; + float Yp2 = (*itPoints).GetPosition()[1]; + /** Extract Indexes from the Dst line to instantiate the line iterator*/ typename LineType::PointListType &pointsListDst = lineDst->GetPoints(); typename LineType::PointListType::const_iterator itPointsDst = pointsListDst.begin(); - + float Xq1 = (*itPointsDst).GetPosition()[0]; //xq1 float Yq1 = (*itPointsDst).GetPosition()[1]; //yq1 ++itPointsDst; @@ -296,7 +296,7 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> float Yq2 = (*itPointsDst).GetPosition()[1]; //yq2 //std::cout << "Xp1 " <<Xp1 <<" Yp1 " << Yp1 << " Xp2 " << Xp2 << " Yp2 "<<Yp2 << " Xq1 " <<Xq1 << " Yq1 "<< Yq1 << " Xq2 " << Xq2<< " Yq2 " << Yq2 << std::endl; - + /** Compute the equation of the lines A and B which are support of the segments Src & Dst*/ // - Line 1 : slope and origin float originA = 0. , slopeA = 0.; @@ -304,36 +304,36 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> float LengthSegmentAy = 0., lengthSegmentBy = 0.; /** Equation of the first Line*/ - if(vcl_abs(Xp2 - Xp1) <1e-10) + if (vcl_abs(Xp2 - Xp1) <1e-10) Xp2 = 0.0001; - if(Xp1 < Xp2 ) + if (Xp1 < Xp2 ) LengthSegmentAy = Yp2 - Yp1; - else + else LengthSegmentAy = Yp1 - Yp2; - + slopeA = LengthSegmentAy/(Xp2-Xp1); originA = Yp1 - (slopeA * Xp1); /** Equation of the second Line*/ - if(vcl_abs(Xq2 - Xq1) <1e-10) + if (vcl_abs(Xq2 - Xq1) <1e-10) Xq2 = 0.0001; - if(Xq1 < Xq2 ) + if (Xq1 < Xq2 ) lengthSegmentBy = Yq2 - Yq1; - else - lengthSegmentBy = Yq1 - Yq2; - + else + lengthSegmentBy = Yq1 - Yq2; + slopeB = lengthSegmentBy/(Xq2-Xq1); originB = Yq1 - (slopeB * Xq1); /** Avoid the case of parallel lines*/ float denum = 0.; - if(vcl_abs(slopeA - slopeB ) < 1e-5) + if (vcl_abs(slopeA - slopeB ) < 1e-5) denum = 0.001; else denum = slopeA - slopeB; - + /** Compute the coordinate of the intersection point Y =AX+B*/ P[0] = (originB - originA)/denum; P[1] = slopeA * static_cast<float>(P[0]) + originA; @@ -357,7 +357,7 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet> VectorLineType vectorLine; vectorLine.push_back(LineDst); vectorLine.push_back(LineCur); - m_OutputPointSet->SetPointData(CurrentPos , vectorLine); + m_OutputPointSet->SetPointData(CurrentPos , vectorLine); } diff --git a/Code/FeatureExtraction/otbMeanTextureFunctor.h b/Code/FeatureExtraction/otbMeanTextureFunctor.h old mode 100755 new mode 100644 index bccc370fb1..0e8867a195 --- a/Code/FeatureExtraction/otbMeanTextureFunctor.h +++ b/Code/FeatureExtraction/otbMeanTextureFunctor.h @@ -39,11 +39,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT MeanTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - MeanTextureFunctor(){}; - virtual ~MeanTextureFunctor(){}; + MeanTextureFunctor() {}; + virtual ~MeanTextureFunctor() {}; typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -54,16 +54,16 @@ public: double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); double areaInv = 1/area; double out = 0.; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; - out += (static_cast<double>(s)+0.5)*this->GetNeighBinLength() * p; - } - } + for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; + out += (static_cast<double>(s)+0.5)*this->GetNeighBinLength() * p; + } + } - return out; + return out; } }; diff --git a/Code/FeatureExtraction/otbPanTexTextureFunctor.h b/Code/FeatureExtraction/otbPanTexTextureFunctor.h index 0a6e546908..2ca6992f01 100644 --- a/Code/FeatureExtraction/otbPanTexTextureFunctor.h +++ b/Code/FeatureExtraction/otbPanTexTextureFunctor.h @@ -39,38 +39,38 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT PanTexTextureFunctor : -public ContrastTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public ContrastTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: PanTexTextureFunctor() - { - OffsetType off; - off[0] = 0; - off[1] = 1; - m_OffsetList.push_back(off); //(0,1) - off[1] = 2; - m_OffsetList.push_back(off); //(0,2) - off[0] = 1; - off[1] = -2; - m_OffsetList.push_back(off); //(1,-2) - off[1] = -1; - m_OffsetList.push_back(off); //(1,-1) - off[1] = 0; - m_OffsetList.push_back(off); //(1,0) - off[1] = 1; - m_OffsetList.push_back(off); //(1,1) - off[1] = 2; - m_OffsetList.push_back(off); //(1,2) - off[0] = 2; - off[1] = -1; - m_OffsetList.push_back(off); //(2,-1) - off[1] = 0; - m_OffsetList.push_back(off); //(2,0) - off[1] = 1; - m_OffsetList.push_back(off); //(2,1) - }; - - virtual ~PanTexTextureFunctor(){}; + { + OffsetType off; + off[0] = 0; + off[1] = 1; + m_OffsetList.push_back(off); //(0,1) + off[1] = 2; + m_OffsetList.push_back(off); //(0,2) + off[0] = 1; + off[1] = -2; + m_OffsetList.push_back(off); //(1,-2) + off[1] = -1; + m_OffsetList.push_back(off); //(1,-1) + off[1] = 0; + m_OffsetList.push_back(off); //(1,0) + off[1] = 1; + m_OffsetList.push_back(off); //(1,1) + off[1] = 2; + m_OffsetList.push_back(off); //(1,2) + off[0] = 2; + off[1] = -1; + m_OffsetList.push_back(off); //(2,-1) + off[1] = 0; + m_OffsetList.push_back(off); //(2,0) + off[1] = 1; + m_OffsetList.push_back(off); //(2,1) + }; + + virtual ~PanTexTextureFunctor() {}; /* typedef TIterInput IterType; @@ -81,30 +81,30 @@ public: typedef itk::Neighborhood<InternalPixelType,::itk::GetImageDimension<ImageType>::ImageDimension> NeighborhoodType; typedef ContrastTextureFunctor<IterType, OutputType> Superclass; */ - typedef TScalarInputPixelType InputScalarType; + typedef TScalarInputPixelType InputScalarType; typedef TScalarOutputPixelType OutputScalarType; typedef ContrastTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::OffsetType OffsetType; typedef typename Superclass::RadiusType RadiusType; typedef typename Superclass::NeighborhoodType NeighborhoodType; virtual double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) + { + // Loop over each offset + double out = itk::NumericTraits<double>::max(); + Superclass contrast; + for (unsigned int k=0; k<m_OffsetList.size(); k++) { - // Loop over each offset - double out = itk::NumericTraits<double>::max(); - Superclass contrast; - for(unsigned int k=0; k<m_OffsetList.size(); k++) - { - contrast.SetOffset( m_OffsetList[k] ); - double res = contrast.ComputeOverSingleChannel(neigh, neighOff); - if(res<out) - out=res; - } + contrast.SetOffset( m_OffsetList[k] ); + double res = contrast.ComputeOverSingleChannel(neigh, neighOff); + if (res<out) + out=res; + } return out; } - private: +private: std::vector<OffsetType> m_OffsetList; }; diff --git a/Code/FeatureExtraction/otbPanTexTextureImageFilter.h b/Code/FeatureExtraction/otbPanTexTextureImageFilter.h index 6737142cdb..a28712a2b6 100644 --- a/Code/FeatureExtraction/otbPanTexTextureImageFilter.h +++ b/Code/FeatureExtraction/otbPanTexTextureImageFilter.h @@ -36,15 +36,15 @@ namespace otb template <class TInputImage, class TOutputImage> class ITK_EXPORT PanTexTextureImageFilter : -public UnaryFunctorNeighborhoodWithOffsetImageFilter< TInputImage, TOutputImage, ITK_TYPENAME Functor::PanTexTextureFunctor< ITK_TYPENAME TInputImage::InternalPixelType, ITK_TYPENAME TOutputImage::InternalPixelType> > + public UnaryFunctorNeighborhoodWithOffsetImageFilter< TInputImage, TOutputImage, ITK_TYPENAME Functor::PanTexTextureFunctor< ITK_TYPENAME TInputImage::InternalPixelType, ITK_TYPENAME TOutputImage::InternalPixelType> > { public: /** Standard class typedefs. */ typedef PanTexTextureImageFilter Self; typedef UnaryFunctorNeighborhoodWithOffsetImageFilter<TInputImage, - TOutputImage, - typename Functor::PanTexTextureFunctor<typename TInputImage::InternalPixelType, - typename TOutputImage::InternalPixelType> > Superclass; + TOutputImage, + typename Functor::PanTexTextureFunctor<typename TInputImage::InternalPixelType, + typename TOutputImage::InternalPixelType> > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -99,9 +99,9 @@ private: //Offset is setted to [2,2] in the publication virtual void SetOffset(OffsetType off) - { - Superclass::SetOffset(off); - }; + { + Superclass::SetOffset(off); + }; }; } // namespace otb diff --git a/Code/FeatureExtraction/otbPanTexTextureImageFilter.txx b/Code/FeatureExtraction/otbPanTexTextureImageFilter.txx index b8e4467d53..6b6d86d000 100644 --- a/Code/FeatureExtraction/otbPanTexTextureImageFilter.txx +++ b/Code/FeatureExtraction/otbPanTexTextureImageFilter.txx @@ -31,7 +31,8 @@ PanTexTextureImageFilter<TInputImage,TOutputImage> ::PanTexTextureImageFilter() { this->SetRadius( 4 ); - OffsetType off; off.Fill(2); + OffsetType off; + off.Fill(2); this->SetOffset( off ); } @@ -54,7 +55,7 @@ PanTexTextureImageFilter<TInputImage, TOutputImage> OutputImagePointer outputPtr = this->GetOutput(0); itk::ImageRegionIterator<TOutputImage> outputIt; - + // Neighborhood+offset iterator RadiusType rOff; rOff[0] = this->GetRadius() + vcl_abs(this->GetOffset()[0]); diff --git a/Code/FeatureExtraction/otbPanTexTextureImageFunctionFilter.h b/Code/FeatureExtraction/otbPanTexTextureImageFunctionFilter.h index c01e9a03ed..b924cda195 100644 --- a/Code/FeatureExtraction/otbPanTexTextureImageFunctionFilter.h +++ b/Code/FeatureExtraction/otbPanTexTextureImageFunctionFilter.h @@ -39,16 +39,16 @@ namespace otb */ template <class TInputImage, class TOutputImage, class TCoordRep = float > -class ITK_EXPORT PanTexTextureImageFunctionFilter : -public FunctionWithNeighborhoodToImageFilter< TInputImage, TOutputImage, - TextureImageFunction<TInputImage, ITK_TYPENAME Functor::PanTexTextureFunctor< ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType>, TCoordRep > > +class ITK_EXPORT PanTexTextureImageFunctionFilter : + public FunctionWithNeighborhoodToImageFilter< TInputImage, TOutputImage, + TextureImageFunction<TInputImage, ITK_TYPENAME Functor::PanTexTextureFunctor< ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType>, TCoordRep > > { - public: +public: /** Standard class typedefs. */ typedef PanTexTextureImageFunctionFilter Self; - typedef FunctionWithNeighborhoodToImageFilter< TInputImage, TOutputImage, - TextureImageFunction<TInputImage, typename Functor::PanTexTextureFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType >, TCoordRep > > Superclass; + typedef FunctionWithNeighborhoodToImageFilter< TInputImage, TOutputImage, + TextureImageFunction<TInputImage, typename Functor::PanTexTextureFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType >, TCoordRep > > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -77,7 +77,7 @@ protected: SizeType radius; radius.Fill(4); this->SetRadius(radius); - + }; ~PanTexTextureImageFunctionFilter() {}; //void PrintSelf(std::ostream& os, itk::Indent indent) const; diff --git a/Code/FeatureExtraction/otbSFSTexturesFunctor.h b/Code/FeatureExtraction/otbSFSTexturesFunctor.h index 8e4365e92e..aff440058c 100644 --- a/Code/FeatureExtraction/otbSFSTexturesFunctor.h +++ b/Code/FeatureExtraction/otbSFSTexturesFunctor.h @@ -27,7 +27,7 @@ namespace otb { /** \class SFSTexturesFunctor * \brief This functor computes textures based on line direction analysis through the central pixel. - * + * * Directions are computed using NumberOfDirection, used to compute a constant step angle. * A direction is defined as : $\mathit{d_{i} = \sqrt{(m^{e1}-m{e2})^{2}+(n^{e1}-n{e2})^{2}}}$ * From $\mathit{d_{i}}, histograms are defined : @@ -71,30 +71,66 @@ public: typedef typename TIter::OffsetType OffsetType; typedef TOutputValue OutputValueType; typedef std::vector<OutputValueType> OutputType; - - void SetSpatialThreshold( unsigned int thresh ){ m_SpatialThreshold=thresh; }; - void SetSpectralThreshold( InternalPixelType thresh ){ m_SpectralThreshold=thresh; }; - void SetRatioMaxConsiderationNumber( unsigned int value ){ m_RatioMaxConsiderationNumber=value; }; - void SetAlpha( double alpha ){ m_Alpha=alpha; }; + + void SetSpatialThreshold( unsigned int thresh ) + { + m_SpatialThreshold=thresh; + }; + void SetSpectralThreshold( InternalPixelType thresh ) + { + m_SpectralThreshold=thresh; + }; + void SetRatioMaxConsiderationNumber( unsigned int value ) + { + m_RatioMaxConsiderationNumber=value; + }; + void SetAlpha( double alpha ) + { + m_Alpha=alpha; + }; void SetNumberOfDirections( unsigned int D ) - { - m_NumberOfDirections = D; - m_DirectionStep = 2*M_PI/static_cast<double>(D); - }; - void SetDirectionStep( double step ){ m_DirectionStep = step; }; + { + m_NumberOfDirections = D; + m_DirectionStep = 2*M_PI/static_cast<double>(D); + }; + void SetDirectionStep( double step ) + { + m_DirectionStep = step; + }; void SetSelectedTextures( std::vector<bool> vect ) - { - m_SelectedTextures.clear(); - m_SelectedTextures = vect; - }; - void SetTextureStatus( unsigned int id, bool isSelected ){ m_SelectedTextures[id] = isSelected; }; - - unsigned int GetSpatialThreshold(){ return m_SpatialThreshold; }; - InternalPixelType GetSpectralThreshold(){ return m_SpectralThreshold; }; - unsigned int GetRatioMaxConsiderationNumber(){ return m_RatioMaxConsiderationNumber; }; - double GetAlpha(){ return m_Alpha; }; - unsigned int GetNumberOfDirections(){ return m_NumberOfDirections(); }; - std::vector<bool> GetTexturesStatus(){ return m_SelectedTextures; }; + { + m_SelectedTextures.clear(); + m_SelectedTextures = vect; + }; + void SetTextureStatus( unsigned int id, bool isSelected ) + { + m_SelectedTextures[id] = isSelected; + }; + + unsigned int GetSpatialThreshold() + { + return m_SpatialThreshold; + }; + InternalPixelType GetSpectralThreshold() + { + return m_SpectralThreshold; + }; + unsigned int GetRatioMaxConsiderationNumber() + { + return m_RatioMaxConsiderationNumber; + }; + double GetAlpha() + { + return m_Alpha; + }; + unsigned int GetNumberOfDirections() + { + return m_NumberOfDirections(); + }; + std::vector<bool> GetTexturesStatus() + { + return m_SelectedTextures; + }; inline OutputType operator()(const TIter& it) { @@ -115,252 +151,252 @@ public: std::vector<double>::iterator itVector; OutputType out(6, 0); - + OffsetType off; off.Fill(0); - - for( unsigned int d = 0; d<m_NumberOfDirections; d++ ) + + for ( unsigned int d = 0; d<m_NumberOfDirections; d++ ) + { + // Current angle direction + angle = m_Alpha*static_cast<double>(d); + + // last offset in the diraction respecting spatial threshold + off[0] = static_cast<int>(vcl_floor(SpatialThresholdDouble*vcl_cos( angle ) + 0.5)); + off[1] = static_cast<int>(vcl_floor(SpatialThresholdDouble*vcl_sin( angle ) + 0.5)); + // last indices in the diration respecting spectral threshold + OffsetType offEnd = this->FindLastOffset( it, off ); + // computes distance = dist between the 2 segment point. One of them is the center pixel -> (0,0) + dist = vcl_sqrt( vcl_pow(static_cast<double>(offEnd[0]), 2 ) + vcl_pow(static_cast<double>(offEnd[1]), 2 ) ); + + // for length computation + if ( m_SelectedTextures[0] == true ) + if ( dist>length ) + length = dist; + + // for width computation + if ( m_SelectedTextures[1] == true ) + if ( dist<width) + width = dist; + + // for PSI computation + if ( m_SelectedTextures[2] == true || m_SelectedTextures[5] == true ) + sum += dist; + + // for w-mean computation + if ( m_SelectedTextures[3] == true ) + sdiVal = this->ComputeSDi(it, offEnd); + + // for Ratio computation + if ( m_SelectedTextures[4] == true ) { - // Current angle direction - angle = m_Alpha*static_cast<double>(d); - - // last offset in the diraction respecting spatial threshold - off[0] = static_cast<int>(vcl_floor(SpatialThresholdDouble*vcl_cos( angle ) + 0.5)); - off[1] = static_cast<int>(vcl_floor(SpatialThresholdDouble*vcl_sin( angle ) + 0.5)); - // last indices in the diration respecting spectral threshold - OffsetType offEnd = this->FindLastOffset( it, off ); - // computes distance = dist between the 2 segment point. One of them is the center pixel -> (0,0) - dist = vcl_sqrt( vcl_pow(static_cast<double>(offEnd[0]), 2 ) + vcl_pow(static_cast<double>(offEnd[1]), 2 ) ); - - // for length computation - if( m_SelectedTextures[0] == true ) - if( dist>length ) - length = dist; - - // for width computation - if( m_SelectedTextures[1] == true ) - if( dist<width) - width = dist; - - // for PSI computation - if( m_SelectedTextures[2] == true || m_SelectedTextures[5] == true ) - sum += dist; - - // for w-mean computation - if( m_SelectedTextures[3] == true ) - sdiVal = this->ComputeSDi(it, offEnd); - - // for Ratio computation - if( m_SelectedTextures[4] == true ) - { - bool doo = false; - itVector = maxSorted.begin(); - while( itVector != maxSorted.end() && doo==false ) - { - if( dist>(*itVector) ) - { - maxSorted.insert(itVector, dist); - maxSorted.pop_back(); - doo=true; - } - ++itVector; - } - doo = false; - itVector = minSorted.begin(); - while( itVector != minSorted.end() && doo==false ) - { - if( dist<(*itVector) ) - { - minSorted.insert(itVector, dist); - minSorted.pop_back(); - doo=true; - } - ++itVector; - } - } - - di[d] = dist; - if( m_SelectedTextures[3] == true ) - { - lengthLine[d] = static_cast<unsigned int>(dist);//static_cast<unsigned int>( vcl_sqrt(vcl_pow(static_cast<double>(offEnd[0]), 2) + vcl_pow(static_cast<double>(offEnd[1]), 2)) ); - sti[d] = sdiVal; - if(sdiVal!=0.) - sumWMean += (m_Alpha*(dist-1)*dist/*lengthLine[n]*di[n]*/)/sdiVal; - } + bool doo = false; + itVector = maxSorted.begin(); + while ( itVector != maxSorted.end() && doo==false ) + { + if ( dist>(*itVector) ) + { + maxSorted.insert(itVector, dist); + maxSorted.pop_back(); + doo=true; + } + ++itVector; + } + doo = false; + itVector = minSorted.begin(); + while ( itVector != minSorted.end() && doo==false ) + { + if ( dist<(*itVector) ) + { + minSorted.insert(itVector, dist); + minSorted.pop_back(); + doo=true; + } + ++itVector; + } } + di[d] = dist; + if ( m_SelectedTextures[3] == true ) + { + lengthLine[d] = static_cast<unsigned int>(dist);//static_cast<unsigned int>( vcl_sqrt(vcl_pow(static_cast<double>(offEnd[0]), 2) + vcl_pow(static_cast<double>(offEnd[1]), 2)) ); + sti[d] = sdiVal; + if (sdiVal!=0.) + sumWMean += (m_Alpha*(dist-1)*dist/*lengthLine[n]*di[n]*/)/sdiVal; + } + } + /////// FILL OUTPUT // length - if( m_SelectedTextures[0] == true ) + if ( m_SelectedTextures[0] == true ) out[0] = static_cast<OutputValueType>(length); // width - if( m_SelectedTextures[1] == true ) + if ( m_SelectedTextures[1] == true ) out[1] = static_cast<OutputValueType>(width); // PSI - if( m_SelectedTextures[2] == true ) + if ( m_SelectedTextures[2] == true ) out[2] = static_cast<OutputValueType>(sum/NumberOfDirectionsDouble); // w-mean - if( m_SelectedTextures[3] == true ) + if ( m_SelectedTextures[3] == true ) out[3] = static_cast<OutputValueType>(sumWMean/NumberOfDirectionsDouble); // ratio - if( m_SelectedTextures[4] == true ) + if ( m_SelectedTextures[4] == true ) + { + double sumMin = 0; + double sumMax = 0; + for (unsigned int t=0; t<m_RatioMaxConsiderationNumber ; t++) { - double sumMin = 0; - double sumMax = 0; - for(unsigned int t=0; t<m_RatioMaxConsiderationNumber ; t++) - { - sumMin += minSorted[t]; - sumMax += maxSorted[t]; - } - if (sumMax != 0.) - out[4] = static_cast<OutputValueType>(vcl_atan(sumMin/sumMax)); - else if (sumMax == 0. && sumMin == 0.) - out[4] = static_cast<OutputValueType>(1.); + sumMin += minSorted[t]; + sumMax += maxSorted[t]; } + if (sumMax != 0.) + out[4] = static_cast<OutputValueType>(vcl_atan(sumMin/sumMax)); + else if (sumMax == 0. && sumMin == 0.) + out[4] = static_cast<OutputValueType>(1.); + } // SD - if( m_SelectedTextures[5] == true ) - { - double sumPSI = 0; - for(unsigned int n=0; n<di.size(); n++) - sumPSI += vcl_pow(di[n] - sumWMean/NumberOfDirectionsDouble , 2); - out[5] = static_cast<OutputValueType>(vcl_sqrt(sumPSI)/(NumberOfDirectionsDouble-1.)); - } - + if ( m_SelectedTextures[5] == true ) + { + double sumPSI = 0; + for (unsigned int n=0; n<di.size(); n++) + sumPSI += vcl_pow(di[n] - sumWMean/NumberOfDirectionsDouble , 2); + out[5] = static_cast<OutputValueType>(vcl_sqrt(sumPSI)/(NumberOfDirectionsDouble-1.)); + } + return out; } - /** Checks spectral threshold condition - * the last point in the directiuon is the first that doesn't + /** Checks spectral threshold condition + * the last point in the directiuon is the first that doesn't * respect the spectral condition. */ OffsetType FindLastOffset( const TIter & it, const OffsetType & stopOffset ) - { - bool res = true; - int signX = this->ComputeStep( stopOffset[0] ); - int signY = this->ComputeStep( stopOffset[1] ); - - OffsetType currentOff; - currentOff.Fill(0); - currentOff[0]=signX; - - double slop = 0.; - if(stopOffset[0]!=0) - slop = static_cast<double>(stopOffset[1] / static_cast<double>(stopOffset[0]) ); - - bool isInside = true; - while( isInside == true && res == true) - { - this->ComputePointLine( currentOff, slop, signY, stopOffset[0] ); - - if( vcl_abs(it.GetPixel(currentOff)-it.GetCenterPixel()) > m_SpectralThreshold ) - { - res = false; - } - else - currentOff[0]+=signX; - - isInside = this->CheckIsInside(signX, signY, currentOff, stopOffset); - } - - return currentOff; + { + bool res = true; + int signX = this->ComputeStep( stopOffset[0] ); + int signY = this->ComputeStep( stopOffset[1] ); + + OffsetType currentOff; + currentOff.Fill(0); + currentOff[0]=signX; + + double slop = 0.; + if (stopOffset[0]!=0) + slop = static_cast<double>(stopOffset[1] / static_cast<double>(stopOffset[0]) ); + + bool isInside = true; + while ( isInside == true && res == true) + { + this->ComputePointLine( currentOff, slop, signY, stopOffset[0] ); + + if ( vcl_abs(it.GetPixel(currentOff)-it.GetCenterPixel()) > m_SpectralThreshold ) + { + res = false; + } + else + currentOff[0]+=signX; + + isInside = this->CheckIsInside(signX, signY, currentOff, stopOffset); } + return currentOff; + } + /** Computes SD in the ith direction */ double ComputeSDi( const TIter & it, const OffsetType & stopOffset) + { + bool canGo = true; + unsigned int nbElt = 0; + double SDi = 0.; + double mean = 0.; + double slop = 0.; + if (stopOffset[0] != 0) + slop = static_cast<double>(stopOffset[1] / static_cast<double>(stopOffset[0]) ); + + int signX = this->ComputeStep( stopOffset[0] ); + int signY = this->ComputeStep( stopOffset[1] ); + + OffsetType currentOff; + currentOff.Fill(0); + currentOff[0]=signX; + + bool isInside = true; + // First compute mean + while ( isInside == true && canGo == true ) { - bool canGo = true; - unsigned int nbElt = 0; - double SDi = 0.; - double mean = 0.; - double slop = 0.; - if(stopOffset[0] != 0) - slop = static_cast<double>(stopOffset[1] / static_cast<double>(stopOffset[0]) ); - - int signX = this->ComputeStep( stopOffset[0] ); - int signY = this->ComputeStep( stopOffset[1] ); - - OffsetType currentOff; - currentOff.Fill(0); - currentOff[0]=signX; - - bool isInside = true; - // First compute mean - while( isInside == true && canGo == true ) - { - this->ComputePointLine( currentOff, slop, signY, stopOffset[0] ); - - mean += static_cast<double>(it.GetPixel(currentOff)); - nbElt++; - - if( vcl_abs(it.GetPixel(currentOff)-it.GetCenterPixel()) >= m_SpectralThreshold ) - canGo = false; - else - currentOff[0]+=signX; - - isInside = this->CheckIsInside(signX, signY, currentOff, stopOffset); - } - - mean /= static_cast<double>(nbElt); - currentOff[0] = signX; - currentOff[1] = 0; - isInside = true; - - while( isInside == true && canGo == true ) - { - this->ComputePointLine( currentOff, slop, signY, stopOffset[0] ); - - SDi += vcl_pow((static_cast<double>(it.GetPixel(currentOff)) - mean), 2); - if( vcl_abs(it.GetPixel(currentOff)-it.GetCenterPixel()) >= m_SpectralThreshold ) - canGo = false; - else - currentOff[0]+=signX; - - isInside = this->CheckIsInside(signX, signY, currentOff, stopOffset); - - } - return vcl_sqrt(SDi); + this->ComputePointLine( currentOff, slop, signY, stopOffset[0] ); + + mean += static_cast<double>(it.GetPixel(currentOff)); + nbElt++; + + if ( vcl_abs(it.GetPixel(currentOff)-it.GetCenterPixel()) >= m_SpectralThreshold ) + canGo = false; + else + currentOff[0]+=signX; + + isInside = this->CheckIsInside(signX, signY, currentOff, stopOffset); } + mean /= static_cast<double>(nbElt); + currentOff[0] = signX; + currentOff[1] = 0; + isInside = true; - /** Check if the current offset is inside the stop one. */ - bool CheckIsInside(const int & signX, const int & signY, const OffsetType & currentOff, const OffsetType & stopOffset) + while ( isInside == true && canGo == true ) { - bool isInside = true; - if( signX*currentOff[0]>=signX*stopOffset[0] && stopOffset[0]!=0) - isInside = false; - else if( signY*currentOff[1]>=signY*stopOffset[1] && stopOffset[1] != 0 ) - isInside = false; + this->ComputePointLine( currentOff, slop, signY, stopOffset[0] ); + + SDi += vcl_pow((static_cast<double>(it.GetPixel(currentOff)) - mean), 2); + if ( vcl_abs(it.GetPixel(currentOff)-it.GetCenterPixel()) >= m_SpectralThreshold ) + canGo = false; + else + currentOff[0]+=signX; + + isInside = this->CheckIsInside(signX, signY, currentOff, stopOffset); - return isInside; } + return vcl_sqrt(SDi); + } + + + /** Check if the current offset is inside the stop one. */ + bool CheckIsInside(const int & signX, const int & signY, const OffsetType & currentOff, const OffsetType & stopOffset) + { + bool isInside = true; + if ( signX*currentOff[0]>=signX*stopOffset[0] && stopOffset[0]!=0) + isInside = false; + else if ( signY*currentOff[1]>=signY*stopOffset[1] && stopOffset[1] != 0 ) + isInside = false; + + return isInside; + } /** Compute the y coordinate according to a given x coordinate. * Use the Bresenham algo if the line is not horizontal (stopOffsetX==0). * Otherwise, it increments of 1 Y. */ void ComputePointLine( OffsetType & currentOff, const double & slop, const int & signY, const int & stopOffsetX ) - { - if(stopOffsetX!=0) - currentOff[1] = static_cast<int>( vcl_floor( slop*static_cast<double>(currentOff[0]) + 0.5 )); - else - currentOff[1]+=signY; - } + { + if (stopOffsetX!=0) + currentOff[1] = static_cast<int>( vcl_floor( slop*static_cast<double>(currentOff[0]) + 0.5 )); + else + currentOff[1]+=signY; + } /** Compute the to give at x for line computation. * according to the signof stopOffset. */ int ComputeStep( const int & stopOffset ) - { - int sign = 1; - if(stopOffset<0) - sign = -1; + { + int sign = 1; + if (stopOffset<0) + sign = -1; - return sign; - } + return sign; + } protected: diff --git a/Code/FeatureExtraction/otbSFSTexturesImageFilter.h b/Code/FeatureExtraction/otbSFSTexturesImageFilter.h index 679e60f92f..1d5e0fa10e 100644 --- a/Code/FeatureExtraction/otbSFSTexturesImageFilter.h +++ b/Code/FeatureExtraction/otbSFSTexturesImageFilter.h @@ -10,8 +10,8 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,8 +39,8 @@ namespace otb * The texture is computated for each pixel using its neighborhood. * User can set the spatial threshold taht is the max line length, the spectral threshold * that is the max difference authorized between a pixel of the line and the center pixel - * of the current neighborhood. Alpha and RationMaxConsideration are used to compute - * the \omega -mean value. Finally, The number of direction can be precised with + * of the current neighborhood. Alpha and RationMaxConsideration are used to compute + * the \omega -mean value. Finally, The number of direction can be precised with * NumberOfDirections. * You can choose the computed textures using SetTextureStatus method (1:length, 2:width, * 3:PSI, 4:w-mean, 5:ratio, 6:SD). @@ -50,7 +50,7 @@ namespace otb template <class TInputImage, class TOutputImage> class ITK_EXPORT SFSTexturesImageFilter : -public itk::ImageToImageFilter<TInputImage,TOutputImage> + public itk::ImageToImageFilter<TInputImage,TOutputImage> { public: /** Standard class typedefs. */ @@ -63,10 +63,10 @@ public: /** Method for creation through the object factory. */ itkNewMacro(Self); - + /** Run-time type information (and related methods). */ itkTypeMacro(UnaryFunctorNeighborhoodImageFilter,ImageToImageFilter); - + /** Some convenient typedefs. */ typedef typename InputImageType::ConstPointer InputImagePointerType; typedef typename InputImageType::RegionType InputImageRegionType; @@ -77,7 +77,7 @@ public: typedef typename OutputImageType::PixelType OutputImagePixelType; typedef itk::ConstNeighborhoodIterator<TInputImage> NeighborhoodIteratorType; typedef typename NeighborhoodIteratorType::RadiusType RadiusType; - typedef Functor::SFSTexturesFunctor< NeighborhoodIteratorType,OutputImagePixelType > FunctorType; + typedef Functor::SFSTexturesFunctor< NeighborhoodIteratorType,OutputImagePixelType > FunctorType; typedef typename FunctorType::OutputType FunctorOutputType; typedef itk::ProcessObject ProcessObjectType; @@ -102,57 +102,57 @@ public: /** Spatial Threshold accessor */ void SetSpatialThreshold( unsigned int thresh ) - { - this->GetFunctor().SetSpatialThreshold( thresh ); - m_Radius = thresh; - this->Modified(); - }; + { + this->GetFunctor().SetSpatialThreshold( thresh ); + m_Radius = thresh; + this->Modified(); + }; unsigned int GetSpatialThreshold() - { - return this->GetFunctor().GetSpatialThreshold(); - }; + { + return this->GetFunctor().GetSpatialThreshold(); + }; /** Spectral Threshold accessor */ void SetSpectralThreshold( InputImagePixelType thresh ) - { - this->GetFunctor().SetSpectralThreshold( thresh ); - }; + { + this->GetFunctor().SetSpectralThreshold( thresh ); + }; InputImagePixelType GetSpectralThreshold() - { - return this->GetFunctor().GetSpectralThreshold(); - }; + { + return this->GetFunctor().GetSpectralThreshold(); + }; /** RatioMaxConsiderationNumber accessor */ void SetRatioMaxConsiderationNumber( unsigned int value ) - { - this->GetFunctor().SetRatioMaxConsiderationNumber(value); - }; + { + this->GetFunctor().SetRatioMaxConsiderationNumber(value); + }; unsigned int GetRatioMaxConsiderationNumber() - { - return this->GetFunctor().GetRatioMaxConsiderationNumber(); - }; - + { + return this->GetFunctor().GetRatioMaxConsiderationNumber(); + }; + /** Alpha accessor */ void SetAlpha( double alpha ) - { - this->GetFunctor().SetAlpha(alpha); - }; + { + this->GetFunctor().SetAlpha(alpha); + }; double GetAlpha() - { - return this->GetFunctor().GetAlpha(); - }; - + { + return this->GetFunctor().GetAlpha(); + }; + /** Number Of Directions */ void SetNumberOfDirections( unsigned int D ) - { - this->GetFunctor().SetNumberOfDirections( D ); - double step = 2*M_PI/static_cast<double>(D); - this->GetFunctor().SetDirectionStep( step ); - }; + { + this->GetFunctor().SetNumberOfDirections( D ); + double step = 2*M_PI/static_cast<double>(D); + this->GetFunctor().SetDirectionStep( step ); + }; unsigned int GetNumberOfDirections() - { - return this->GetFunctor().GetNumberOfDirections(); - }; + { + return this->GetFunctor().GetNumberOfDirections(); + }; - /** Texture selection accessors + /** Texture selection accessors * 1: length * 2: width * 3: PSI @@ -162,29 +162,29 @@ public: * Set to 1 means the texture will be computed. **/ void SetTextureStatus( unsigned int id, bool isSelected ) + { + if ( id>this->GetTexturesStatus().size() || id == 0 ) { - if ( id>this->GetTexturesStatus().size() || id == 0 ) - { - itkExceptionMacro(<<"Invalid texture index "<<id<<", must be in [1;"<<this->GetTexturesStatus().size()<<"]"); - } - else - { - this->GetFunctor().SetTextureStatus( id-1, isSelected ); - } + itkExceptionMacro(<<"Invalid texture index "<<id<<", must be in [1;"<<this->GetTexturesStatus().size()<<"]"); } - std::vector<bool> GetTexturesStatus() + else { - return this->GetFunctor().GetTexturesStatus(); + this->GetFunctor().SetTextureStatus( id-1, isSelected ); } + } + std::vector<bool> GetTexturesStatus() + { + return this->GetFunctor().GetTexturesStatus(); + } void InitTextureStatusFalse() + { + unsigned int id; + for (id=1;id<=6;id++) { - unsigned int id; - for (id=1;id<=6;id++) - { - this->SetTextureStatus(id,false); - } + this->SetTextureStatus(id,false); } + } @@ -192,34 +192,34 @@ public: const OutputImageType * GetLengthOutput() const; OutputImageType * GetLengthOutput(); - /** Return output width image */ + /** Return output width image */ const OutputImageType * GetWidthOutput() const; OutputImageType * GetWidthOutput(); /** Return output PSI image */ const OutputImageType * GetPSIOutput() const; OutputImageType * GetPSIOutput(); - + /** Return output WMean image */ const OutputImageType * GetWMeanOutput() const; OutputImageType * GetWMeanOutput(); - + /** Return output ratio image */ const OutputImageType * GetRatioOutput() const; OutputImageType * GetRatioOutput(); - + /** Return output SD image */ const OutputImageType * GetSDOutput() const; OutputImageType * GetSDOutput(); - + virtual void GenerateOutputInformation(); std::vector<FunctorType> m_FunctorList; protected: SFSTexturesImageFilter(); - virtual ~SFSTexturesImageFilter(){}; + virtual ~SFSTexturesImageFilter() {}; void PrintSelf(std::ostream& os, itk::Indent indent) const; virtual void BeforeThreadedGenerateData(); diff --git a/Code/FeatureExtraction/otbSFSTexturesImageFilter.txx b/Code/FeatureExtraction/otbSFSTexturesImageFilter.txx index a04fbb48bd..bfb1ce50ba 100644 --- a/Code/FeatureExtraction/otbSFSTexturesImageFilter.txx +++ b/Code/FeatureExtraction/otbSFSTexturesImageFilter.txx @@ -36,7 +36,7 @@ SFSTexturesImageFilter<TInputImage,TOutputImage> this->SetNumberOfRequiredInputs( 1 ); this->SetNumberOfOutputs(6); this->SetNumberOfRequiredOutputs(1); - + this->SetNthOutput(0,OutputImageType::New()); this->SetNthOutput(1,OutputImageType::New()); this->SetNthOutput(2,OutputImageType::New()); @@ -94,9 +94,9 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { return 0; } - if (this->GetTexturesStatus()[1] == false) + if (this->GetTexturesStatus()[1] == false) { - itkExceptionMacro(<<"Impossible to create width image : texture not selected"); + itkExceptionMacro(<<"Impossible to create width image : texture not selected"); } return static_cast<const OutputImageType * > (this->itk::ProcessObject::GetOutput(1) ); } @@ -109,14 +109,14 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { return 0; } - if (this->GetTexturesStatus()[1] == false) + if (this->GetTexturesStatus()[1] == false) { itkExceptionMacro(<<"Impossible to create width image : texture not selected"); } return static_cast<OutputImageType * >(this->itk::ProcessObject::GetOutput(1) ); } -//Return output PSI image +//Return output PSI image template <class TInputImage, class TOutputImage> const typename SFSTexturesImageFilter<TInputImage, TOutputImage>::OutputImageType * SFSTexturesImageFilter<TInputImage, TOutputImage> @@ -126,7 +126,7 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { return 0; } - if (this->GetTexturesStatus()[2] == false) + if (this->GetTexturesStatus()[2] == false) { itkExceptionMacro(<<"Impossible to create PSI image : texture not selected"); } @@ -174,7 +174,7 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { return 0; } - if (this->GetTexturesStatus()[3] == false) + if (this->GetTexturesStatus()[3] == false) { itkExceptionMacro(<<"Impossible to create W-Mean image : texture not selected"); } @@ -191,7 +191,7 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { return 0; } - if (this->GetTexturesStatus()[4] == false) + if (this->GetTexturesStatus()[4] == false) { itkExceptionMacro(<<"Impossible to create Ratio image : texture not selected"); } @@ -223,7 +223,7 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { return 0; } - if (this->GetTexturesStatus()[5] == false) + if (this->GetTexturesStatus()[5] == false) { itkExceptionMacro(<<"Impossible to create SD image : texture not selected"); } @@ -254,16 +254,16 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> ::BeforeThreadedGenerateData() { Superclass::BeforeThreadedGenerateData(); - if(this->GetSpatialThreshold() < this->GetRatioMaxConsiderationNumber()) - { - itkExceptionMacro(<<"Spatial Threshold ("<<this->GetSpatialThreshold() - <<") is lower than Ration Max Consideration Number (" - <<this->GetRatioMaxConsiderationNumber()<<") what is not allowed."); - } + if (this->GetSpatialThreshold() < this->GetRatioMaxConsiderationNumber()) + { + itkExceptionMacro(<<"Spatial Threshold ("<<this->GetSpatialThreshold() + <<") is lower than Ration Max Consideration Number (" + <<this->GetRatioMaxConsiderationNumber()<<") what is not allowed."); + } for (int i =0; i<this->GetNumberOfThreads(); i++) - { - m_FunctorList.push_back(m_Functor); - } + { + m_FunctorList.push_back(m_Functor); + } } template <class TInputImage, class TOutputImage> @@ -379,14 +379,14 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> for (fit=faceList.begin(); fit != faceList.end(); ++fit) { neighInputIt = itk::ConstNeighborhoodIterator<TInputImage>(r, inputPtr, *fit); - + outputIt1 = itk::ImageRegionIterator<TOutputImage>(outputPtr1, *fit); outputIt2 = itk::ImageRegionIterator<TOutputImage>(outputPtr2, *fit); outputIt3 = itk::ImageRegionIterator<TOutputImage>(outputPtr3, *fit); outputIt4 = itk::ImageRegionIterator<TOutputImage>(outputPtr4, *fit); outputIt5 = itk::ImageRegionIterator<TOutputImage>(outputPtr5, *fit); outputIt6 = itk::ImageRegionIterator<TOutputImage>(outputPtr6, *fit); - + std::vector< itk::ImageRegionIterator<TOutputImage> *> outItList; outItList.push_back(&outputIt1); outItList.push_back(&outputIt2); @@ -394,31 +394,31 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> outItList.push_back(&outputIt4); outItList.push_back(&outputIt5); outItList.push_back(&outputIt6); - + neighInputIt.OverrideBoundaryCondition(&nbc); neighInputIt.GoToBegin(); - - for(unsigned int i = 0; i<outItList.size(); i++) - { - (*outItList[i]).GoToBegin(); - } - + + for (unsigned int i = 0; i<outItList.size(); i++) + { + (*outItList[i]).GoToBegin(); + } + while ( !outputIt1.IsAtEnd() ) { - outputFunctor = m_FunctorList[threadId]( neighInputIt); - for(unsigned int i = 0; i<outItList.size(); i++) - { - if( textStatus[i]==true ) - (*outItList[i]).Set( outputFunctor[i] ); - } - + outputFunctor = m_FunctorList[threadId]( neighInputIt); + for (unsigned int i = 0; i<outItList.size(); i++) + { + if ( textStatus[i]==true ) + (*outItList[i]).Set( outputFunctor[i] ); + } + ++neighInputIt; - for(unsigned int i = 0; i<outItList.size(); i++) - { - ++(*outItList[i]); - } - + for (unsigned int i = 0; i<outItList.size(); i++) + { + ++(*outItList[i]); + } + progress.CompletedPixel(); } } @@ -435,13 +435,13 @@ SFSTexturesImageFilter<TInputImage, TOutputImage> { Superclass::PrintSelf( os, indent ); - + //os << indent << "Spatial Threshold : " << this->GetSpatialThreshold() << std::endl; //os << indent << "Spectral Threshold : " << this->GetSpectralThreshold() << std::endl; //os << indent << "Ratio Max Consideration Number: " << this->GetRatioMaxConsiderationNumber() << std::endl; //os << indent << "Alpha : " << this->GetAlpha() << std::endl; //os << indent << "Number Of Directions : " << this->GetNumberOfDirections() << std::endl; - + } diff --git a/Code/FeatureExtraction/otbSumAverageTextureFunctor.h b/Code/FeatureExtraction/otbSumAverageTextureFunctor.h old mode 100755 new mode 100644 index ae80a64211..c54d1128ba --- a/Code/FeatureExtraction/otbSumAverageTextureFunctor.h +++ b/Code/FeatureExtraction/otbSumAverageTextureFunctor.h @@ -38,50 +38,50 @@ namespace Functor */ template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT SumAverageTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - SumAverageTextureFunctor(){}; - virtual ~SumAverageTextureFunctor(){}; - + SumAverageTextureFunctor() {}; + virtual ~SumAverageTextureFunctor() {}; + typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; virtual double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) + { + this->ComputeJointHistogram(neigh, neighOff); + double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); + double areaInv = 1/area; + double out = 0.; + // loop over bin neighborhood values + for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) { - this->ComputeJointHistogram(neigh, neighOff); - double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); - double areaInv = 1/area; - double out = 0.; - // loop over bin neighborhood values - for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) - { - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - double nCeil2 = (static_cast<double>(sB)+this->GetHisto()[0].size()+0.5)*this->GetNeighBinLength(); - double Px_y = 0.; - double Px_y2 = 0.; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double sVal = (static_cast<double>(s)+0.5)*this->GetNeighBinLength(); - if( vcl_abs(rVal + sVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - if( vcl_abs(rVal + sVal - nCeil2) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y2 += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - } - } - out += nCeil * Px_y + nCeil2 * Px_y2; - } - - return out; + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + double nCeil2 = (static_cast<double>(sB)+this->GetHisto()[0].size()+0.5)*this->GetNeighBinLength(); + double Px_y = 0.; + double Px_y2 = 0.; + for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double sVal = (static_cast<double>(s)+0.5)*this->GetNeighBinLength(); + if ( vcl_abs(rVal + sVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + if ( vcl_abs(rVal + sVal - nCeil2) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y2 += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + } + } + out += nCeil * Px_y + nCeil2 * Px_y2; } + return out; + } + }; diff --git a/Code/FeatureExtraction/otbSumEntropyTextureFunctor.h b/Code/FeatureExtraction/otbSumEntropyTextureFunctor.h old mode 100755 new mode 100644 index 92e835f13b..db3c36e9be --- a/Code/FeatureExtraction/otbSumEntropyTextureFunctor.h +++ b/Code/FeatureExtraction/otbSumEntropyTextureFunctor.h @@ -38,12 +38,12 @@ namespace Functor */ template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT SumEntropyTextureFunctor : -public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> + public TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> { public: - SumEntropyTextureFunctor(){}; - virtual ~SumEntropyTextureFunctor(){}; - + SumEntropyTextureFunctor() {}; + virtual ~SumEntropyTextureFunctor() {}; + typedef TextureFunctorBase<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -55,35 +55,35 @@ public: double out = 0.; // loop over bin neighborhood values for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) + { + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + double nCeil2 = (static_cast<double>(sB)+this->GetHisto()[0].size()+0.5)*this->GetNeighBinLength(); + double Px_y = 0.; + double Px_y2 = 0.; + for (unsigned r = 0; r<this->GetHisto().size(); r++) { - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - double nCeil2 = (static_cast<double>(sB)+this->GetHisto()[0].size()+0.5)*this->GetNeighBinLength(); - double Px_y = 0.; - double Px_y2 = 0.; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double sVal = (static_cast<double>(s)+0.5)*this->GetNeighBinLength(); - if( vcl_abs(rVal + sVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - if( vcl_abs(rVal + sVal - nCeil2) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y2 += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - } - } - if(Px_y != 0.) - out += Px_y * vcl_log(Px_y); - if(Px_y2 != 0.) - out += Px_y2 * vcl_log(Px_y2); + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double sVal = (static_cast<double>(s)+0.5)*this->GetNeighBinLength(); + if ( vcl_abs(rVal + sVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + if ( vcl_abs(rVal + sVal - nCeil2) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y2 += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + } } + if (Px_y != 0.) + out += Px_y * vcl_log(Px_y); + if (Px_y2 != 0.) + out += Px_y2 * vcl_log(Px_y2); + } - if(out != 0) + if (out != 0) out = -out; diff --git a/Code/FeatureExtraction/otbSumVarianceTextureFunctor.h b/Code/FeatureExtraction/otbSumVarianceTextureFunctor.h old mode 100755 new mode 100644 index be391e6dc8..0f7aaad6e4 --- a/Code/FeatureExtraction/otbSumVarianceTextureFunctor.h +++ b/Code/FeatureExtraction/otbSumVarianceTextureFunctor.h @@ -40,12 +40,12 @@ namespace Functor */ template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT SumVarianceTextureFunctor : -public SumAverageTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public SumAverageTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: - SumVarianceTextureFunctor(){}; - virtual ~SumVarianceTextureFunctor(){}; - + SumVarianceTextureFunctor() {}; + virtual ~SumVarianceTextureFunctor() {}; + typedef SumAverageTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -57,29 +57,29 @@ public: double areaInv = 1/area; double out = 0.; for (unsigned sB = 0; sB<this->GetHisto()[0].size(); sB++) + { + double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); + double nCeil2 = (static_cast<double>(sB)+this->GetHisto()[0].size()+0.5)*this->GetNeighBinLength(); + double Px_y = 0.; + double Px_y2 = 0.; + for (unsigned r = 0; r<this->GetHisto().size(); r++) { - double nCeil = (static_cast<double>(sB)+0.5)*this->GetNeighBinLength(); - double nCeil2 = (static_cast<double>(sB)+this->GetHisto()[0].size()+0.5)*this->GetNeighBinLength(); - double Px_y = 0.; - double Px_y2 = 0.; - for (unsigned r = 0; r<this->GetHisto().size(); r++) - { - double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double sVal = (static_cast<double>(s)+0.5)*this->GetNeighBinLength(); - if( vcl_abs(rVal + sVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - if( vcl_abs(rVal + sVal - nCeil2) < vcl_abs(this->GetNeighBinLength()) ) - { - Px_y2 += static_cast<double>(this->GetHisto()[r][s])*areaInv; - } - } - } - out += vcl_pow((nCeil-f6), 2)*Px_y + vcl_pow((nCeil2-f6), 2)*Px_y2; + double rVal = (static_cast<double>(r)+0.5)*this->GetOffsetBinLength(); + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) + { + double sVal = (static_cast<double>(s)+0.5)*this->GetNeighBinLength(); + if ( vcl_abs(rVal + sVal - nCeil) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + if ( vcl_abs(rVal + sVal - nCeil2) < vcl_abs(this->GetNeighBinLength()) ) + { + Px_y2 += static_cast<double>(this->GetHisto()[r][s])*areaInv; + } + } } + out += vcl_pow((nCeil-f6), 2)*Px_y + vcl_pow((nCeil2-f6), 2)*Px_y2; + } return out; } @@ -88,7 +88,7 @@ public: - } // namespace Functor +} // namespace Functor } // namespace otb #endif diff --git a/Code/FeatureExtraction/otbTextureFunctorBase.h b/Code/FeatureExtraction/otbTextureFunctorBase.h old mode 100755 new mode 100644 index 50152c7ecb..058b591823 --- a/Code/FeatureExtraction/otbTextureFunctorBase.h +++ b/Code/FeatureExtraction/otbTextureFunctorBase.h @@ -34,13 +34,13 @@ namespace Functor /** \class TextureFunctorBase * \brief This functor is the base for all texture functors. * - * It uses a neighborhood iterator which radius is the one of the considered + * It uses a neighborhood iterator which radius is the one of the considered * neighborhood plsu an offset (m_Offset) to compute texture. * It computes the mean, standard deviation of the two areas and the joint histogram using * Scott formula for the bins lengths computation. * TIterInput is an iterator, TOutput is a PixelType. * - * \ingroup Functor + * \ingroup Functor * \ingroup Statistics */ @@ -78,96 +78,135 @@ public: typedef std::vector<IntVectorType> IntVectorVectorType; - void SetOffset(OffsetType off){ m_Offset=off; }; - OffsetType GetOffset(){ return m_Offset; }; - double GetMaxi(){ return m_Maxi; }; - double GetMini(){ return m_Mini; }; - double GetMaxiOff(){ return m_MaxiOff; }; - double GetMiniOff(){ return m_MiniOff; }; - double GetMean(){ return m_Mean; }; - double GetMeanOff(){ return m_MeanOff; }; - double GetStd(){ return m_Std; }; - double GetStdOff(){ return m_StdOff;}; - double GetNeighBinLength(){ return m_NeighBinLength; }; - double GetOffsetBinLength(){ return m_OffsetBinLength; }; - IntVectorVectorType GetHisto(){ return m_Histo; }; - - /** Computes the histogram bins using Scott formula, plus min/max, means, stds */ + void SetOffset(OffsetType off) + { + m_Offset=off; + }; + OffsetType GetOffset() + { + return m_Offset; + }; + double GetMaxi() + { + return m_Maxi; + }; + double GetMini() + { + return m_Mini; + }; + double GetMaxiOff() + { + return m_MaxiOff; + }; + double GetMiniOff() + { + return m_MiniOff; + }; + double GetMean() + { + return m_Mean; + }; + double GetMeanOff() + { + return m_MeanOff; + }; + double GetStd() + { + return m_Std; + }; + double GetStdOff() + { + return m_StdOff; + }; + double GetNeighBinLength() + { + return m_NeighBinLength; + }; + double GetOffsetBinLength() + { + return m_OffsetBinLength; + }; + IntVectorVectorType GetHisto() + { + return m_Histo; + }; + + /** Computes the histogram bins using Scott formula, plus min/max, means, stds */ void StatComputation(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) + { + double binLength = 0; + double binLengthOff =0; + m_Mean = 0.; + m_MeanOff = 0.; + m_Std = 0.; + m_StdOff = 0.; + RadiusType radius = neigh.GetRadius(); + m_Mini = itk::NumericTraits<double>::max(); + m_MiniOff = itk::NumericTraits<double>::max(); + m_Maxi = itk::NumericTraits<double>::NonpositiveMin(); + m_MaxiOff = itk::NumericTraits<double>::NonpositiveMin(); + double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); + double areaInv = 1/area; + double scottCoef = 3.5 /(vcl_pow(area, 1/3) ); + + OffsetType offset; + offset.Fill(0); + OffsetType offsetOff; + OffsetType offsetOffInit; + + offsetOffInit[0] = -radius[0]+this->GetOffset()[0]-1; + offsetOffInit[1] = -radius[1]+this->GetOffset()[1]-1; + + offsetOff = offsetOffInit; + for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) { - double binLength = 0; - double binLengthOff =0; - m_Mean = 0.; - m_MeanOff = 0.; - m_Std = 0.; - m_StdOff = 0.; - RadiusType radius = neigh.GetRadius(); - m_Mini = itk::NumericTraits<double>::max(); - m_MiniOff = itk::NumericTraits<double>::max(); - m_Maxi = itk::NumericTraits<double>::NonpositiveMin(); - m_MaxiOff = itk::NumericTraits<double>::NonpositiveMin(); - double area = static_cast<double>(neigh.GetSize()[0]*neigh.GetSize()[1]); - double areaInv = 1/area; - double scottCoef = 3.5 /(vcl_pow(area, 1/3) ); - - OffsetType offset; - offset.Fill(0); - OffsetType offsetOff; - OffsetType offsetOffInit; - - offsetOffInit[0] = -radius[0]+this->GetOffset()[0]-1; - offsetOffInit[1] = -radius[1]+this->GetOffset()[1]-1; - - offsetOff = offsetOffInit; - for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) - { - offsetOff[0]++; - offsetOff[1] = offsetOffInit[1]; - offset[0] = l; - for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) - { - offsetOff[1]++; - offset[1] = k; - m_Mean += static_cast<double>(neigh[offset]); - m_MeanOff += static_cast<double>(neighOff[offsetOff]); - - m_Mini = std::min(static_cast<double>(neigh[offset]), m_Mini); - m_Maxi = std::max(static_cast<double>(neigh[offset]), m_Maxi); - m_MiniOff = std::min(static_cast<double>(neighOff[offsetOff]),m_MiniOff); - m_MaxiOff = std::max(static_cast<double>(neighOff[offsetOff]),m_MaxiOff); - } - } - m_Mean *= areaInv; - m_MeanOff *= areaInv; - - offsetOff = offsetOffInit; - - for( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) - { - offsetOff[0]++; - offsetOff[1] = offsetOffInit[1]; - offset[0] = l; - for( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) - { - offsetOff[1]++; - offset[1] = k; - binLength += vcl_pow( (m_Mean-static_cast<double>(neigh[offset])), 2); - binLengthOff += vcl_pow( (m_MeanOff-static_cast<double>(neighOff[offsetOff])), 2); - } - } - - binLength *= areaInv; - binLength = vcl_sqrt( binLength ); - binLengthOff *= areaInv; - binLengthOff = vcl_sqrt( binLengthOff ); - m_Std = binLength; - m_StdOff = binLengthOff; - - m_NeighBinLength = scottCoef*binLength; - m_OffsetBinLength = scottCoef*binLengthOff; + offsetOff[0]++; + offsetOff[1] = offsetOffInit[1]; + offset[0] = l; + for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) + { + offsetOff[1]++; + offset[1] = k; + m_Mean += static_cast<double>(neigh[offset]); + m_MeanOff += static_cast<double>(neighOff[offsetOff]); + + m_Mini = std::min(static_cast<double>(neigh[offset]), m_Mini); + m_Maxi = std::max(static_cast<double>(neigh[offset]), m_Maxi); + m_MiniOff = std::min(static_cast<double>(neighOff[offsetOff]),m_MiniOff); + m_MaxiOff = std::max(static_cast<double>(neighOff[offsetOff]),m_MaxiOff); + } + } + m_Mean *= areaInv; + m_MeanOff *= areaInv; + + offsetOff = offsetOffInit; + + for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) + { + offsetOff[0]++; + offsetOff[1] = offsetOffInit[1]; + offset[0] = l; + for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) + { + offsetOff[1]++; + offset[1] = k; + binLength += vcl_pow( (m_Mean-static_cast<double>(neigh[offset])), 2); + binLengthOff += vcl_pow( (m_MeanOff-static_cast<double>(neighOff[offsetOff])), 2); + } } -inline OutputScalarType operator()(const NeighborhoodType &neigh) + binLength *= areaInv; + binLength = vcl_sqrt( binLength ); + binLengthOff *= areaInv; + binLengthOff = vcl_sqrt( binLengthOff ); + m_Std = binLength; + m_StdOff = binLengthOff; + + m_NeighBinLength = scottCoef*binLength; + m_OffsetBinLength = scottCoef*binLengthOff; + } + + inline OutputScalarType operator()(const NeighborhoodType &neigh) { RadiusType radiusOff = neigh.GetRadius(); //OutputScalarType outPix; @@ -179,136 +218,136 @@ inline OutputScalarType operator()(const NeighborhoodType &neigh) RadiusType radius; radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) ); radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) ); - + NeighborhoodType inNeigh; inNeigh.SetRadius(radius); NeighborhoodType offNeigh; offNeigh.SetRadius(radiusOff); - // Extract the neighborhood area + // Extract the neighborhood area for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) + { + offset[0] = l; + for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) { - offset[0] = l; - for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) - { - offset[1] = k; - inNeigh[offset] = neigh[offset];//neigh.GetPixel(offset); - } + offset[1] = k; + inNeigh[offset] = neigh[offset];//neigh.GetPixel(offset); } + } // Extract the offset area offset.Fill(0); for ( int l = -static_cast<int>(radiusOff[0]); l <= static_cast<int>(radiusOff[0]); l++ ) + { + offset[0] = l; + for ( int k = -static_cast<int>(radiusOff[1]); k <= static_cast<int>(radiusOff[1]); k++) { - offset[0] = l; - for ( int k = -static_cast<int>(radiusOff[1]); k <= static_cast<int>(radiusOff[1]); k++) - { - offset[1] = k; - offNeigh[offset] = neigh[offset];//neigh.GetPixel(offset); - } + offset[1] = k; + offNeigh[offset] = neigh[offset];//neigh.GetPixel(offset); } + } OutputScalarType outPix = static_cast<OutputScalarType>( this->ComputeOverSingleChannel(inNeigh, offNeigh) ); - + return outPix; } inline OutputVectorType operator()(const NeighborhoodVectorType &neigh) - { - RadiusType radiusOff = neigh.GetRadius(); - OutputVectorType outPix; - outPix.SetSize( neigh.GetCenterValue/*Pixel*/().GetSize() ); - outPix.Fill(0); - OffsetType offset; + { + RadiusType radiusOff = neigh.GetRadius(); + OutputVectorType outPix; + outPix.SetSize( neigh.GetCenterValue/*Pixel*/().GetSize() ); + outPix.Fill(0); + OffsetType offset; + offset.Fill(0); + // Compute the neighborhood radius from the neigh+offset iterator to extract the neighborhood area from the iterator + RadiusType radius; + radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) ); + radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) ); + + // For each channel + for ( unsigned int i=0; i<neigh.GetCenterValue/*Pixel*/().GetSize(); i++ ) + { + NeighborhoodType inNeigh; + inNeigh.SetRadius(radius); + NeighborhoodType offNeigh; + offNeigh.SetRadius(radiusOff); + // Extract the neighborhood area + for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) + { + offset[0] = l; + for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) + { + offset[1] = k; + inNeigh[offset] = neigh[offset][i];//neigh.GetPixel(offset)[i]; + } + } + // Extract the offset area offset.Fill(0); - // Compute the neighborhood radius from the neigh+offset iterator to extract the neighborhood area from the iterator - RadiusType radius; - radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) ); - radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) ); - - // For each channel - for ( unsigned int i=0; i<neigh.GetCenterValue/*Pixel*/().GetSize(); i++ ) - { - NeighborhoodType inNeigh; - inNeigh.SetRadius(radius); - NeighborhoodType offNeigh; - offNeigh.SetRadius(radiusOff); - // Extract the neighborhood area - for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) - { - offset[0] = l; - for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) - { - offset[1] = k; - inNeigh[offset] = neigh[offset][i];//neigh.GetPixel(offset)[i]; - } - } - // Extract the offset area - offset.Fill(0); - for ( int l = -static_cast<int>(radiusOff[0]); l <= static_cast<int>(radiusOff[0]); l++ ) - { - offset[0] = l; - for ( int k = -static_cast<int>(radiusOff[1]); k <= static_cast<int>(radiusOff[1]); k++) - { - offset[1] = k; - offNeigh[offset] = neigh[offset][i]; - } - } - outPix[i] = static_cast<OutputScalarType>( this->ComputeOverSingleChannel(inNeigh, offNeigh) ); - } - return outPix; + for ( int l = -static_cast<int>(radiusOff[0]); l <= static_cast<int>(radiusOff[0]); l++ ) + { + offset[0] = l; + for ( int k = -static_cast<int>(radiusOff[1]); k <= static_cast<int>(radiusOff[1]); k++) + { + offset[1] = k; + offNeigh[offset] = neigh[offset][i]; + } + } + outPix[i] = static_cast<OutputScalarType>( this->ComputeOverSingleChannel(inNeigh, offNeigh) ); } + return outPix; + } void ComputeJointHistogram(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) + { + this->StatComputation(neigh, neighOff); + + RadiusType radius = neigh.GetRadius(); + OffsetType offset; + offset.Fill(0); + OffsetType offsetOff; + OffsetType offsetOffInit; + + offsetOffInit[0] = -radius[0]+this->GetOffset()[0]-1; + offsetOffInit[1] = -radius[1]+this->GetOffset()[1]-1; + + int histoIdX = 0; + int histoIdY = 0; + + IntVectorType histoTemp; + if (m_NeighBinLength != 0) + histoTemp = IntVectorType( static_cast<unsigned int>(vcl_floor( static_cast<double>(this->GetMaxi()-this->GetMini())/m_NeighBinLength)+1.), 0); + else + histoTemp = IntVectorType( 1, 0 ); + + if (m_OffsetBinLength != 0) + m_Histo = IntVectorVectorType( static_cast<unsigned int>(vcl_floor(static_cast<double>(this->GetMaxiOff()-this->GetMiniOff())/m_OffsetBinLength)+1.), histoTemp ); + else + m_Histo = IntVectorVectorType( 1, histoTemp ); + + offsetOff = offsetOffInit; + for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) { - this->StatComputation(neigh, neighOff); - - RadiusType radius = neigh.GetRadius(); - OffsetType offset; - offset.Fill(0); - OffsetType offsetOff; - OffsetType offsetOffInit; - - offsetOffInit[0] = -radius[0]+this->GetOffset()[0]-1; - offsetOffInit[1] = -radius[1]+this->GetOffset()[1]-1; - - int histoIdX = 0; - int histoIdY = 0; - - IntVectorType histoTemp; - if (m_NeighBinLength != 0) - histoTemp = IntVectorType( static_cast<unsigned int>(vcl_floor( static_cast<double>(this->GetMaxi()-this->GetMini())/m_NeighBinLength)+1.), 0); - else - histoTemp = IntVectorType( 1, 0 ); - - if (m_OffsetBinLength != 0) - m_Histo = IntVectorVectorType( static_cast<unsigned int>(vcl_floor(static_cast<double>(this->GetMaxiOff()-this->GetMiniOff())/m_OffsetBinLength)+1.), histoTemp ); - else - m_Histo = IntVectorVectorType( 1, histoTemp ); - - offsetOff = offsetOffInit; - for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) - { - offsetOff[0]++; - offsetOff[1] = offsetOffInit[1]; - offset[0] = l; - for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) - { - offsetOff[1]++; - offset[1] = k; - histoIdX = 0; - histoIdY = 0; - if ( m_OffsetBinLength != 0) - histoIdX = static_cast<int>(vcl_floor( (static_cast<double>(neighOff[offsetOff])-this->GetMiniOff()) / static_cast<double>(m_OffsetBinLength) )); - if ( m_NeighBinLength !=0 ) - histoIdY = static_cast<int>(vcl_floor( (static_cast<double>(neigh[offset])-this->GetMini()) /static_cast<double>( m_NeighBinLength) )); - - m_Histo[histoIdX][histoIdY]++; - - } - } + offsetOff[0]++; + offsetOff[1] = offsetOffInit[1]; + offset[0] = l; + for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++) + { + offsetOff[1]++; + offset[1] = k; + histoIdX = 0; + histoIdY = 0; + if ( m_OffsetBinLength != 0) + histoIdX = static_cast<int>(vcl_floor( (static_cast<double>(neighOff[offsetOff])-this->GetMiniOff()) / static_cast<double>(m_OffsetBinLength) )); + if ( m_NeighBinLength !=0 ) + histoIdY = static_cast<int>(vcl_floor( (static_cast<double>(neigh[offset])-this->GetMini()) /static_cast<double>( m_NeighBinLength) )); + + m_Histo[histoIdX][histoIdY]++; + + } } + } virtual double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff) = 0; - - private: + +private: OffsetType m_Offset; /** Stores min/max neighborhood area values */ double m_Mini; diff --git a/Code/FeatureExtraction/otbTextureImageFunction.h b/Code/FeatureExtraction/otbTextureImageFunction.h index 482c6268d6..125b7f43d6 100644 --- a/Code/FeatureExtraction/otbTextureImageFunction.h +++ b/Code/FeatureExtraction/otbTextureImageFunction.h @@ -38,9 +38,9 @@ namespace otb */ template <class TInputImage, class TFunctor, class TCoordRep = float > class ITK_EXPORT TextureImageFunction : - public itk::ImageFunction< TInputImage, ITK_TYPENAME itk::NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep > + public itk::ImageFunction< TInputImage, ITK_TYPENAME itk::NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep > { - public: +public: /** Standard class typedefs. */ typedef TextureImageFunction Self; typedef itk::ImageFunction<TInputImage, ITK_TYPENAME itk::NumericTraits<typename TInputImage::PixelType>::RealType, @@ -67,7 +67,7 @@ class ITK_EXPORT TextureImageFunction : typedef itk::ConstNeighborhoodIterator<InputImageType> IteratorType; typedef typename IteratorType::NeighborhoodType NeighborhoodType; typedef typename itk::NumericTraits<typename InputImageType::PixelType>::RealType RealType; - + /** Dimension of the underlying image. */ itkStaticConstMacro(ImageDimension, unsigned int,InputImageType::ImageDimension); @@ -90,7 +90,7 @@ class ITK_EXPORT TextureImageFunction : this->ConvertContinuousIndexToNearestIndex( cindex, index ); return this->EvaluateAtIndex( index ) ; }; - + /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ void SetRadius(SizeType & rad) @@ -98,7 +98,7 @@ class ITK_EXPORT TextureImageFunction : m_Radius = rad; this->Modified(); }; - + void SetOffset(OffsetType & off) { m_Offset = off; diff --git a/Code/FeatureExtraction/otbTextureImageFunction.txx b/Code/FeatureExtraction/otbTextureImageFunction.txx index e80d82e3c1..773118ab55 100644 --- a/Code/FeatureExtraction/otbTextureImageFunction.txx +++ b/Code/FeatureExtraction/otbTextureImageFunction.txx @@ -77,7 +77,7 @@ TextureImageFunction<TInputImage, TFunctor, TCoordRep> FunctorType funct; funct.SetOffset(m_Offset); - + return static_cast<RealType>(funct( itOff.GetNeighborhood() )); } diff --git a/Code/FeatureExtraction/otbVarianceTextureFunctor.h b/Code/FeatureExtraction/otbVarianceTextureFunctor.h old mode 100755 new mode 100644 index 55f0d3016c..af6c25a517 --- a/Code/FeatureExtraction/otbVarianceTextureFunctor.h +++ b/Code/FeatureExtraction/otbVarianceTextureFunctor.h @@ -41,11 +41,11 @@ namespace Functor template <class TScalarInputPixelType, class TScalarOutputPixelType> class ITK_EXPORT VarianceTextureFunctor : -public MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> + public MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> { public: - VarianceTextureFunctor(){}; - virtual ~VarianceTextureFunctor(){}; + VarianceTextureFunctor() {}; + virtual ~VarianceTextureFunctor() {}; typedef MeanTextureFunctor<TScalarInputPixelType, TScalarOutputPixelType> Superclass; typedef typename Superclass::NeighborhoodType NeighborhoodType; @@ -59,14 +59,14 @@ public: double areaInv = 1/area; double out = 0.; for (unsigned r = 0; r<this->GetHisto().size(); r++) + { + for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { - for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) - { - double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; - double square = vcl_pow( ( ( (static_cast<double>(s)+0.5)*this->GetNeighBinLength() ) - mean), 2); - out += square*p; - } + double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; + double square = vcl_pow( ( ( (static_cast<double>(s)+0.5)*this->GetNeighBinLength() ) - mean), 2); + out += square*p; } + } return out; } diff --git a/Code/IO/otbImageSeriesFileReader.h b/Code/IO/otbImageSeriesFileReader.h index 4dae2cc62b..94e20cd135 100644 --- a/Code/IO/otbImageSeriesFileReader.h +++ b/Code/IO/otbImageSeriesFileReader.h @@ -31,103 +31,104 @@ #include "otbMultiChannelExtractROI.h" #include "otbMultiToMonoChannelExtractROI.h" -namespace otb { +namespace otb +{ template < class TImage, class TInternalImage = TImage > class ITK_EXPORT ImageSeriesFileReader - : public ImageSeriesFileReaderBase< TImage, TInternalImage > + : public ImageSeriesFileReaderBase< TImage, TInternalImage > { - public: - /** Standart typedefs */ - typedef ImageSeriesFileReader Self; - typedef ImageSeriesFileReaderBase< TImage, TInternalImage > Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Creation through object factory macro */ - itkNewMacro(Self); - /** Runtime informations macro */ - itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); - - typedef typename Superclass::OutputImageType OutputImageType; - typedef typename Superclass::OutputImagePointerType OutputImagePointerType; - typedef typename Superclass::PixelType PixelType; - typedef typename Superclass::ValueType ValueType; - typedef typename Superclass::IndexType IndexType; - typedef typename Superclass::SizeType SizeType; - typedef typename Superclass::RegionType RegionType; - - typedef typename Superclass::OutputImageListType OutputImageListType; - typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; - typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; - - typedef typename Superclass::InternalImageType InternalImageType; - typedef typename Superclass::InternalImagePointerType InternalImagePointerType; - typedef typename Superclass::InternalPixelType InternalPixelType; - typedef typename Superclass::InternalValueType InternalValueType; - typedef typename Superclass::InternalIndexType InternalIndexType; - typedef typename Superclass::InternalSizeType InternalSizeType; - typedef typename Superclass::InternalRegionType InternalRegionType; - - typedef typename Superclass::ReaderType ReaderType; - typedef typename Superclass::ReaderType ReaderPointerType; - - typedef typename Superclass::ReaderListType ReaderListType; - typedef typename Superclass::ReaderListPointerType ReaderListPointerType; - - /** This is a generic template definition of the ROI extraction procedure. - * In fact, it will be specialised with: - * - MultiChannelExtractROI if TImage is a VectorImage - * - MultiToMonoChannelExtractROI if TImage is an Image and TInteranalImage is a VectorImage - * - ExtractROI if TImage and TInternalImage are of Image type. - */ - // typedef MultiChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; - // typedef MultiToMonoChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; - // typedef ExtractROI< InternalPixelType, PixelType > ExtractSelectionType; - typedef itk::ImageToImageFilter< InternalImageType, OutputImageType > ExtractSelectionType; - typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; - - typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; - typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; - - protected: - ImageSeriesFileReader(); - virtual ~ImageSeriesFileReader () { } - - /** - * Tests the coherency of the Meta File (especifically band selection) with the image types - */ - virtual void TestBandSelection( std::vector<unsigned int> & bands ) { } - - /** GenerateData - * This method will be specialised if template definitions follow: - * - TImage is a VectorImage - * - TImage is an Image and TInteranalImage is a VectorImage - * - TImage and TInternalImage are of Image type. - */ - virtual void GenerateData ( unsigned int idx ); - - /** - * Once MetaFile is read, allocation of lists are performed in SetFileName. - * This allows specific (or global) initialisation in the GenerateData methods, - * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). - */ - virtual void AllocateListOfComponents ( void ); - - /** PrintSelf method */ - void PrintSelf ( std::ostream& os, itk::Indent indent ) const - { - return Superclass::PrintSelf( os, indent ); - } - - /** - * Type of extractor to use - */ - ExtractSelectionListPointerType m_ExtractorList; - - private: - ImageSeriesFileReader ( const Self & ); - void operator= ( const Self & ); +public: + /** Standart typedefs */ + typedef ImageSeriesFileReader Self; + typedef ImageSeriesFileReaderBase< TImage, TInternalImage > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Runtime informations macro */ + itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); + + typedef typename Superclass::OutputImageType OutputImageType; + typedef typename Superclass::OutputImagePointerType OutputImagePointerType; + typedef typename Superclass::PixelType PixelType; + typedef typename Superclass::ValueType ValueType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::SizeType SizeType; + typedef typename Superclass::RegionType RegionType; + + typedef typename Superclass::OutputImageListType OutputImageListType; + typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; + typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; + + typedef typename Superclass::InternalImageType InternalImageType; + typedef typename Superclass::InternalImagePointerType InternalImagePointerType; + typedef typename Superclass::InternalPixelType InternalPixelType; + typedef typename Superclass::InternalValueType InternalValueType; + typedef typename Superclass::InternalIndexType InternalIndexType; + typedef typename Superclass::InternalSizeType InternalSizeType; + typedef typename Superclass::InternalRegionType InternalRegionType; + + typedef typename Superclass::ReaderType ReaderType; + typedef typename Superclass::ReaderType ReaderPointerType; + + typedef typename Superclass::ReaderListType ReaderListType; + typedef typename Superclass::ReaderListPointerType ReaderListPointerType; + + /** This is a generic template definition of the ROI extraction procedure. + * In fact, it will be specialised with: + * - MultiChannelExtractROI if TImage is a VectorImage + * - MultiToMonoChannelExtractROI if TImage is an Image and TInteranalImage is a VectorImage + * - ExtractROI if TImage and TInternalImage are of Image type. + */ + // typedef MultiChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; + // typedef MultiToMonoChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; + // typedef ExtractROI< InternalPixelType, PixelType > ExtractSelectionType; + typedef itk::ImageToImageFilter< InternalImageType, OutputImageType > ExtractSelectionType; + typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; + + typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; + typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; + +protected: + ImageSeriesFileReader(); + virtual ~ImageSeriesFileReader () { } + + /** + * Tests the coherency of the Meta File (especifically band selection) with the image types + */ + virtual void TestBandSelection( std::vector<unsigned int> & bands ) { } + + /** GenerateData + * This method will be specialised if template definitions follow: + * - TImage is a VectorImage + * - TImage is an Image and TInteranalImage is a VectorImage + * - TImage and TInternalImage are of Image type. + */ + virtual void GenerateData ( unsigned int idx ); + + /** + * Once MetaFile is read, allocation of lists are performed in SetFileName. + * This allows specific (or global) initialisation in the GenerateData methods, + * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). + */ + virtual void AllocateListOfComponents ( void ); + + /** PrintSelf method */ + void PrintSelf ( std::ostream& os, itk::Indent indent ) const + { + return Superclass::PrintSelf( os, indent ); + } + + /** + * Type of extractor to use + */ + ExtractSelectionListPointerType m_ExtractorList; + +private: + ImageSeriesFileReader ( const Self & ); + void operator= ( const Self & ); }; // end of class /** ImagerSeriesFileReader @@ -142,93 +143,93 @@ class ITK_EXPORT ImageSeriesFileReader */ template < class TPixel, class TInternalPixel > class ITK_EXPORT ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > - : public ImageSeriesFileReaderBase< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > + : public ImageSeriesFileReaderBase< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > { - public: - /** Standart typedefs */ - typedef ImageSeriesFileReader Self; - typedef ImageSeriesFileReaderBase< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Creation through object factory macro */ - itkNewMacro(Self); - /** Runtime informations macro */ - itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); - - typedef typename Superclass::OutputImageType OutputImageType; - typedef typename Superclass::OutputImagePointerType OutputImagePointerType; - typedef typename Superclass::PixelType PixelType; - typedef typename Superclass::ValueType ValueType; - typedef typename Superclass::IndexType IndexType; - typedef typename Superclass::SizeType SizeType; - typedef typename Superclass::RegionType RegionType; - - typedef typename Superclass::OutputImageListType OutputImageListType; - typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; - typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; - - typedef typename Superclass::InternalImageType InternalImageType; - typedef typename Superclass::InternalImagePointerType InternalImagePointerType; - typedef typename Superclass::InternalPixelType InternalPixelType; - typedef typename Superclass::InternalValueType InternalValueType; - typedef typename Superclass::InternalIndexType InternalIndexType; - typedef typename Superclass::InternalSizeType InternalSizeType; - typedef typename Superclass::InternalRegionType InternalRegionType; - - typedef typename Superclass::ReaderType ReaderType; - typedef typename Superclass::ReaderType ReaderPointerType; - - typedef typename Superclass::ReaderListType ReaderListType; - typedef typename Superclass::ReaderListPointerType ReaderListPointerType; - - /** This is a specialised template definition of the ROI extraction procedure. - * Here TExtractSelection is a ExtractROI class since TImage and TInternalImage are of Image type. - */ - typedef ExtractROI< InternalPixelType, PixelType > ExtractSelectionType; - typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; - - typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; - typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; - - protected: - ImageSeriesFileReader(); - virtual ~ImageSeriesFileReader () { } - - /** - * Tests the coherency of the Meta File (especifically band selection) with the image types - */ - virtual void TestBandSelection( std::vector<unsigned int> & bands ) ; - - /** GenerateData - * This method will be specialised if template definitions follow: - * - TImage is a VectorImage - * - TImage is an Image and TInteranalImage is a VectorImage - * - TImage and TInternalImage are of Image type. - */ - virtual void GenerateData ( unsigned int idx ); - - /** - * Once MetaFile is read, allocation of lists are performed in SetFileName. - * This allows specific (or global) initialisation in the GenerateData methods, - * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). - */ - virtual void AllocateListOfComponents ( void ); - - /** PrintSelf method */ - void PrintSelf ( std::ostream& os, itk::Indent indent ) const - { - return Superclass::PrintSelf( os, indent ); - } - - /** - * Type of extractor to use - */ - ExtractSelectionListPointerType m_ExtractorList; - - private: - ImageSeriesFileReader ( const Self & ); - void operator= ( const Self & ); +public: + /** Standart typedefs */ + typedef ImageSeriesFileReader Self; + typedef ImageSeriesFileReaderBase< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Runtime informations macro */ + itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); + + typedef typename Superclass::OutputImageType OutputImageType; + typedef typename Superclass::OutputImagePointerType OutputImagePointerType; + typedef typename Superclass::PixelType PixelType; + typedef typename Superclass::ValueType ValueType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::SizeType SizeType; + typedef typename Superclass::RegionType RegionType; + + typedef typename Superclass::OutputImageListType OutputImageListType; + typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; + typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; + + typedef typename Superclass::InternalImageType InternalImageType; + typedef typename Superclass::InternalImagePointerType InternalImagePointerType; + typedef typename Superclass::InternalPixelType InternalPixelType; + typedef typename Superclass::InternalValueType InternalValueType; + typedef typename Superclass::InternalIndexType InternalIndexType; + typedef typename Superclass::InternalSizeType InternalSizeType; + typedef typename Superclass::InternalRegionType InternalRegionType; + + typedef typename Superclass::ReaderType ReaderType; + typedef typename Superclass::ReaderType ReaderPointerType; + + typedef typename Superclass::ReaderListType ReaderListType; + typedef typename Superclass::ReaderListPointerType ReaderListPointerType; + + /** This is a specialised template definition of the ROI extraction procedure. + * Here TExtractSelection is a ExtractROI class since TImage and TInternalImage are of Image type. + */ + typedef ExtractROI< InternalPixelType, PixelType > ExtractSelectionType; + typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; + + typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; + typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; + +protected: + ImageSeriesFileReader(); + virtual ~ImageSeriesFileReader () { } + + /** + * Tests the coherency of the Meta File (especifically band selection) with the image types + */ + virtual void TestBandSelection( std::vector<unsigned int> & bands ) ; + + /** GenerateData + * This method will be specialised if template definitions follow: + * - TImage is a VectorImage + * - TImage is an Image and TInteranalImage is a VectorImage + * - TImage and TInternalImage are of Image type. + */ + virtual void GenerateData ( unsigned int idx ); + + /** + * Once MetaFile is read, allocation of lists are performed in SetFileName. + * This allows specific (or global) initialisation in the GenerateData methods, + * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). + */ + virtual void AllocateListOfComponents ( void ); + + /** PrintSelf method */ + void PrintSelf ( std::ostream& os, itk::Indent indent ) const + { + return Superclass::PrintSelf( os, indent ); + } + + /** + * Type of extractor to use + */ + ExtractSelectionListPointerType m_ExtractorList; + +private: + ImageSeriesFileReader ( const Self & ); + void operator= ( const Self & ); }; // end of class specialized for image @@ -244,93 +245,93 @@ class ITK_EXPORT ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixe */ template < class TPixel, class TInternalPixel > class ITK_EXPORT ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > - : public ImageSeriesFileReaderBase< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > + : public ImageSeriesFileReaderBase< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > { - public: - /** Standart typedefs */ - typedef ImageSeriesFileReader Self; - typedef ImageSeriesFileReaderBase< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Creation through object factory macro */ - itkNewMacro(Self); - /** Runtime informations macro */ - itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); - - typedef typename Superclass::OutputImageType OutputImageType; - typedef typename Superclass::OutputImagePointerType OutputImagePointerType; - typedef typename Superclass::PixelType PixelType; - typedef typename Superclass::ValueType ValueType; - typedef typename Superclass::IndexType IndexType; - typedef typename Superclass::SizeType SizeType; - typedef typename Superclass::RegionType RegionType; - - typedef typename Superclass::OutputImageListType OutputImageListType; - typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; - typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; - - typedef typename Superclass::InternalImageType InternalImageType; - typedef typename Superclass::InternalImagePointerType InternalImagePointerType; - typedef typename Superclass::InternalPixelType InternalPixelType; - typedef typename Superclass::InternalValueType InternalValueType; - typedef typename Superclass::InternalIndexType InternalIndexType; - typedef typename Superclass::InternalSizeType InternalSizeType; - typedef typename Superclass::InternalRegionType InternalRegionType; - - typedef typename Superclass::ReaderType ReaderType; - typedef typename Superclass::ReaderType ReaderPointerType; - - typedef typename Superclass::ReaderListType ReaderListType; - typedef typename Superclass::ReaderListPointerType ReaderListPointerType; - - /** This is a specific template definition of the ROI extraction procedure. - * MultiToMonoChannelExtractROI since TImage is an Image and TInteranalImage is a VectorImage - */ - typedef MultiToMonoChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; - typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; - - typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; - typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; - - protected: - ImageSeriesFileReader(); - virtual ~ImageSeriesFileReader () { } - - /** - * Tests the coherency of the Meta File (especifically band selection) with the image types - */ - virtual void TestBandSelection( std::vector<unsigned int> & bands ) ; - - /** GenerateData - * This method will be specialised if template definitions follow: - * - TImage is a VectorImage - * - TImage is an Image and TInteranalImage is a VectorImage - * - TImage and TInternalImage are of Image type. - */ - virtual void GenerateData ( unsigned int idx ); - - /** - * Once MetaFile is read, allocation of lists are performed in SetFileName. - * This allows specific (or global) initialisation in the GenerateData methods, - * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). - */ - virtual void AllocateListOfComponents ( void ); - - /** PrintSelf method */ - void PrintSelf ( std::ostream& os, itk::Indent indent ) const - { - return Superclass::PrintSelf( os, indent ); - } - - /** - * Type of extractor to use - */ - ExtractSelectionListPointerType m_ExtractorList; - - private: - ImageSeriesFileReader ( const Self & ); - void operator= ( const Self & ); +public: + /** Standart typedefs */ + typedef ImageSeriesFileReader Self; + typedef ImageSeriesFileReaderBase< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Runtime informations macro */ + itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); + + typedef typename Superclass::OutputImageType OutputImageType; + typedef typename Superclass::OutputImagePointerType OutputImagePointerType; + typedef typename Superclass::PixelType PixelType; + typedef typename Superclass::ValueType ValueType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::SizeType SizeType; + typedef typename Superclass::RegionType RegionType; + + typedef typename Superclass::OutputImageListType OutputImageListType; + typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; + typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; + + typedef typename Superclass::InternalImageType InternalImageType; + typedef typename Superclass::InternalImagePointerType InternalImagePointerType; + typedef typename Superclass::InternalPixelType InternalPixelType; + typedef typename Superclass::InternalValueType InternalValueType; + typedef typename Superclass::InternalIndexType InternalIndexType; + typedef typename Superclass::InternalSizeType InternalSizeType; + typedef typename Superclass::InternalRegionType InternalRegionType; + + typedef typename Superclass::ReaderType ReaderType; + typedef typename Superclass::ReaderType ReaderPointerType; + + typedef typename Superclass::ReaderListType ReaderListType; + typedef typename Superclass::ReaderListPointerType ReaderListPointerType; + + /** This is a specific template definition of the ROI extraction procedure. + * MultiToMonoChannelExtractROI since TImage is an Image and TInteranalImage is a VectorImage + */ + typedef MultiToMonoChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; + typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; + + typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; + typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; + +protected: + ImageSeriesFileReader(); + virtual ~ImageSeriesFileReader () { } + + /** + * Tests the coherency of the Meta File (especifically band selection) with the image types + */ + virtual void TestBandSelection( std::vector<unsigned int> & bands ) ; + + /** GenerateData + * This method will be specialised if template definitions follow: + * - TImage is a VectorImage + * - TImage is an Image and TInteranalImage is a VectorImage + * - TImage and TInternalImage are of Image type. + */ + virtual void GenerateData ( unsigned int idx ); + + /** + * Once MetaFile is read, allocation of lists are performed in SetFileName. + * This allows specific (or global) initialisation in the GenerateData methods, + * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). + */ + virtual void AllocateListOfComponents ( void ); + + /** PrintSelf method */ + void PrintSelf ( std::ostream& os, itk::Indent indent ) const + { + return Superclass::PrintSelf( os, indent ); + } + + /** + * Type of extractor to use + */ + ExtractSelectionListPointerType m_ExtractorList; + +private: + ImageSeriesFileReader ( const Self & ); + void operator= ( const Self & ); }; // end of class specialized for Image and VectorImage @@ -347,94 +348,94 @@ class ITK_EXPORT ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TIntern */ template < class TPixel, class TInternalPixel > class ITK_EXPORT ImageSeriesFileReader< VectorImage< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > - : public ImageSeriesFileReaderBase< VectorImage< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > + : public ImageSeriesFileReaderBase< VectorImage< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > { - public: - /** Standart typedefs */ - typedef ImageSeriesFileReader Self; - typedef ImageSeriesFileReaderBase< VectorImage< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Creation through object factory macro */ - itkNewMacro(Self); - /** Runtime informations macro */ - itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); - - typedef typename Superclass::OutputImageType OutputImageType; - typedef typename Superclass::OutputImagePointerType OutputImagePointerType; - typedef typename Superclass::PixelType PixelType; - typedef typename Superclass::ValueType ValueType; - typedef typename Superclass::IndexType IndexType; - typedef typename Superclass::SizeType SizeType; - typedef typename Superclass::RegionType RegionType; - - typedef typename Superclass::OutputImageListType OutputImageListType; - typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; - typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; - - typedef typename Superclass::InternalImageType InternalImageType; - typedef typename Superclass::InternalImagePointerType InternalImagePointerType; - typedef typename Superclass::InternalPixelType InternalPixelType; - typedef typename Superclass::InternalValueType InternalValueType; - typedef typename Superclass::InternalIndexType InternalIndexType; - typedef typename Superclass::InternalSizeType InternalSizeType; - typedef typename Superclass::InternalRegionType InternalRegionType; - - typedef typename Superclass::ReaderType ReaderType; - typedef typename Superclass::ReaderType ReaderPointerType; - - typedef typename Superclass::ReaderListType ReaderListType; - typedef typename Superclass::ReaderListPointerType ReaderListPointerType; - - /** This is a specific template definition of the ROI extraction procedure. - * Here, it will be specialised with: - * MultiChannelExtractROI if TImage is a VectorImage - */ - typedef MultiChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; - typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; - - typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; - typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; - - protected: - ImageSeriesFileReader(); - virtual ~ImageSeriesFileReader () { } - - /** - * Tests the coherency of the Meta File (especifically band selection) with the image types - */ - virtual void TestBandSelection( std::vector<unsigned int> & bands ){ } - - /** GenerateData - * This method will be specialised if template definitions follow: - * - TImage is a VectorImage - * - TImage is an Image and TInteranalImage is a VectorImage - * - TImage and TInternalImage are of Image type. - */ - virtual void GenerateData ( unsigned int idx ); - - /** - * Once MetaFile is read, allocation of lists are performed in SetFileName. - * This allows specific (or global) initialisation in the GenerateData methods, - * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). - */ - virtual void AllocateListOfComponents ( void ); - - /** PrintSelf method */ - void PrintSelf ( std::ostream& os, itk::Indent indent ) const - { - return Superclass::PrintSelf( os, indent ); - } - - /** - * Type of extractor to use - */ - ExtractSelectionListPointerType m_ExtractorList; - - private: - ImageSeriesFileReader ( const Self & ); - void operator= ( const Self & ); +public: + /** Standart typedefs */ + typedef ImageSeriesFileReader Self; + typedef ImageSeriesFileReaderBase< VectorImage< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Runtime informations macro */ + itkTypeMacro(ImageSeriesFileReader,ImageSeriesFileReaderBase); + + typedef typename Superclass::OutputImageType OutputImageType; + typedef typename Superclass::OutputImagePointerType OutputImagePointerType; + typedef typename Superclass::PixelType PixelType; + typedef typename Superclass::ValueType ValueType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::SizeType SizeType; + typedef typename Superclass::RegionType RegionType; + + typedef typename Superclass::OutputImageListType OutputImageListType; + typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType; + typedef typename Superclass::OutputImageListConstPointerType OutputImageListConstPointerType; + + typedef typename Superclass::InternalImageType InternalImageType; + typedef typename Superclass::InternalImagePointerType InternalImagePointerType; + typedef typename Superclass::InternalPixelType InternalPixelType; + typedef typename Superclass::InternalValueType InternalValueType; + typedef typename Superclass::InternalIndexType InternalIndexType; + typedef typename Superclass::InternalSizeType InternalSizeType; + typedef typename Superclass::InternalRegionType InternalRegionType; + + typedef typename Superclass::ReaderType ReaderType; + typedef typename Superclass::ReaderType ReaderPointerType; + + typedef typename Superclass::ReaderListType ReaderListType; + typedef typename Superclass::ReaderListPointerType ReaderListPointerType; + + /** This is a specific template definition of the ROI extraction procedure. + * Here, it will be specialised with: + * MultiChannelExtractROI if TImage is a VectorImage + */ + typedef MultiChannelExtractROI< InternalPixelType, PixelType > ExtractSelectionType; + typedef typename ExtractSelectionType::Pointer ExtractSelectionPointerType; + + typedef ObjectList< ExtractSelectionType > ExtractSelectionListType; + typedef typename ExtractSelectionListType::Pointer ExtractSelectionListPointerType; + +protected: + ImageSeriesFileReader(); + virtual ~ImageSeriesFileReader () { } + + /** + * Tests the coherency of the Meta File (especifically band selection) with the image types + */ + virtual void TestBandSelection( std::vector<unsigned int> & bands ) { } + + /** GenerateData + * This method will be specialised if template definitions follow: + * - TImage is a VectorImage + * - TImage is an Image and TInteranalImage is a VectorImage + * - TImage and TInternalImage are of Image type. + */ + virtual void GenerateData ( unsigned int idx ); + + /** + * Once MetaFile is read, allocation of lists are performed in SetFileName. + * This allows specific (or global) initialisation in the GenerateData methods, + * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). + */ + virtual void AllocateListOfComponents ( void ); + + /** PrintSelf method */ + void PrintSelf ( std::ostream& os, itk::Indent indent ) const + { + return Superclass::PrintSelf( os, indent ); + } + + /** + * Type of extractor to use + */ + ExtractSelectionListPointerType m_ExtractorList; + +private: + ImageSeriesFileReader ( const Self & ); + void operator= ( const Self & ); }; // end of class specialized for VectorImage } // end of namespace otb diff --git a/Code/IO/otbImageSeriesFileReader.txx b/Code/IO/otbImageSeriesFileReader.txx index 0d49de28e0..bd55ec414b 100644 --- a/Code/IO/otbImageSeriesFileReader.txx +++ b/Code/IO/otbImageSeriesFileReader.txx @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,10 +23,11 @@ #include "otbImageSeriesFileReader.h" -namespace otb { +namespace otb +{ template < class TImage, class TInternalImage > -ImageSeriesFileReader< TImage, TInternalImage > +ImageSeriesFileReader< TImage, TInternalImage > ::ImageSeriesFileReader () { this->m_OutputList = OutputImageListType::New(); @@ -36,7 +37,7 @@ ImageSeriesFileReader< TImage, TInternalImage > template < class TImage, class TInternalImage > void -ImageSeriesFileReader< TImage, TInternalImage > +ImageSeriesFileReader< TImage, TInternalImage > ::AllocateListOfComponents () { for ( unsigned int i = 0; i < this->GetNumberOfOutputs(); i++ ) @@ -49,14 +50,14 @@ ImageSeriesFileReader< TImage, TInternalImage > template < class TImage, class TInternalImage > void -ImageSeriesFileReader< TImage, TInternalImage > +ImageSeriesFileReader< TImage, TInternalImage > ::GenerateData( unsigned int idx ) { - itk::OStringStream msg; - msg << "Something wrong... Check the template definition of this class in the program...\n"; - msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); - throw e; + itk::OStringStream msg; + msg << "Something wrong... Check the template definition of this class in the program...\n"; + msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); + throw e; } /* ********************************************************** @@ -90,7 +91,7 @@ ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > } /** - * TestBandSelection tests if the templated Image type is compatible + * TestBandSelection tests if the templated Image type is compatible * with the bande selection provided in the Meta File */ template < class TPixel, class TInternalPixel > @@ -98,24 +99,24 @@ void ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > ::TestBandSelection ( std::vector<unsigned int> & bands ) { - if ( bands.size() != 1 ) - { - itk::OStringStream msg; - msg << "Unable to handle multicomponent file from Image<> class\n"; - msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); - throw e; - } - - if ( bands[0] != 1 ) - { - itk::OStringStream msg; - msg << "Unable to handle given band reading from multicomponent file with Image<> class\n"; - msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); - throw e; - } - return; + if ( bands.size() != 1 ) + { + itk::OStringStream msg; + msg << "Unable to handle multicomponent file from Image<> class\n"; + msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); + throw e; + } + + if ( bands[0] != 1 ) + { + itk::OStringStream msg; + msg << "Unable to handle given band reading from multicomponent file with Image<> class\n"; + msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); + throw e; + } + return; } /** @@ -126,13 +127,13 @@ void ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > ::GenerateData( unsigned int idx ) { - ReaderType * reader - = static_cast<ReaderType*>( this->m_ImageFileReaderList->GetNthElement( idx ) ); + ReaderType * reader + = static_cast<ReaderType*>( this->m_ImageFileReaderList->GetNthElement( idx ) ); reader->SetFileName( this->m_ListOfFileNames[ idx ] ); ExtractSelectionType * selection - = static_cast<ExtractSelectionType*>( m_ExtractorList->GetNthElement( idx ) ); + = static_cast<ExtractSelectionType*>( m_ExtractorList->GetNthElement( idx ) ); selection->SetExtractionRegion( this->m_ListOfRegionSelection[ idx ] ); @@ -144,7 +145,7 @@ ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixel, 2 > > } /* ********************************************************************* - * Methods that are specific to instanciation with Image type for TImage + * Methods that are specific to instanciation with Image type for TImage * and VectorImage as TInternalImage * ********************************************************************* */ @@ -178,7 +179,7 @@ ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > } /** - * TestBandSelection tests if the templated Image type is compatible + * TestBandSelection tests if the templated Image type is compatible * with the bande selection provided in the Meta File */ template < class TPixel, class TInternalPixel > @@ -186,35 +187,35 @@ void ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > ::TestBandSelection ( std::vector<unsigned int> & bands ) { - if ( bands.size() != 1 ) - { - itk::OStringStream msg; - msg << "Unable to handle multicomponent file from Image<> class as output\n"; - msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); - throw e; - } - return; + if ( bands.size() != 1 ) + { + itk::OStringStream msg; + msg << "Unable to handle multicomponent file from Image<> class as output\n"; + msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n"; + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); + throw e; + } + return; } /** - * GenerateData for Image type as output and VectorImage type for reading + * GenerateData for Image type as output and VectorImage type for reading */ template < class TPixel, class TInternalPixel > void ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > ::GenerateData( unsigned int idx ) { - ReaderType * reader - = static_cast<ReaderType*>( this->m_ImageFileReaderList->GetNthElement( idx ) ); + ReaderType * reader + = static_cast<ReaderType*>( this->m_ImageFileReaderList->GetNthElement( idx ) ); reader->SetFileName( this->m_ListOfFileNames[ idx ] ); ExtractSelectionType * selection - = static_cast<ExtractSelectionType*>( this->m_ExtractorList->GetNthElement( idx ) ); + = static_cast<ExtractSelectionType*>( this->m_ExtractorList->GetNthElement( idx ) ); selection->SetExtractionRegion( this->m_ListOfRegionSelection[ idx ] ); - selection->SetChannel( this->m_ListOfBandSelection[ idx ][0] ); + selection->SetChannel( this->m_ListOfBandSelection[ idx ][0] ); selection->SetInput( reader->GetOutput() ); selection->GraftOutput( this->m_OutputList->GetNthElement( idx ) ); @@ -224,7 +225,7 @@ ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > } /* ****************************************************************** - * Methods that are specific to instanciation with VectorImage types + * Methods that are specific to instanciation with VectorImage types * ****************************************************************** */ @@ -264,22 +265,22 @@ void ImageSeriesFileReader< VectorImage< TPixel, 2 >, VectorImage< TInternalPixel, 2 > > ::GenerateData( unsigned int idx ) { - ReaderType * reader - = static_cast<ReaderType*>( this->m_ImageFileReaderList->GetNthElement( idx ) ); + ReaderType * reader + = static_cast<ReaderType*>( this->m_ImageFileReaderList->GetNthElement( idx ) ); reader->SetFileName( this->m_ListOfFileNames[ idx ] ); ExtractSelectionType * selection - = static_cast<ExtractSelectionType*>( this->m_ExtractorList->GetNthElement( idx ) ); + = static_cast<ExtractSelectionType*>( this->m_ExtractorList->GetNthElement( idx ) ); selection->SetExtractionRegion( this->m_ListOfRegionSelection[ idx ] ); - for ( std::vector<unsigned int>::iterator band = this->m_ListOfBandSelection[ idx ].begin(); - band != this->m_ListOfBandSelection[ idx ].end(); - ++band ) - { - selection->SetChannel( *band ); - } + for ( std::vector<unsigned int>::iterator band = this->m_ListOfBandSelection[ idx ].begin(); + band != this->m_ListOfBandSelection[ idx ].end(); + ++band ) + { + selection->SetChannel( *band ); + } selection->SetInput( reader->GetOutput() ); selection->GraftOutput( this->m_OutputList->GetNthElement( idx ) ); diff --git a/Code/IO/otbImageSeriesFileReaderBase.h b/Code/IO/otbImageSeriesFileReaderBase.h index cd06103cf4..0ceb2ebc52 100644 --- a/Code/IO/otbImageSeriesFileReaderBase.h +++ b/Code/IO/otbImageSeriesFileReaderBase.h @@ -36,140 +36,141 @@ #include "otbImageListSource.h" #include "otbImageFileReader.h" -namespace otb { +namespace otb +{ - class ImageSeriesFileReaderException : public itk::ExceptionObject - { - public: - itkTypeMacro( ImageSeriesFileReaderException, ExceptionObject ); +class ImageSeriesFileReaderException : public itk::ExceptionObject +{ +public: + itkTypeMacro( ImageSeriesFileReaderException, ExceptionObject ); - ImageSeriesFileReaderException(const char *file, unsigned int line, + ImageSeriesFileReaderException(const char *file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown") : - itk::ExceptionObject(file, line, message, loc) { } + itk::ExceptionObject(file, line, message, loc) { } - ImageSeriesFileReaderException(const std::string &file, unsigned int line, + ImageSeriesFileReaderException(const std::string &file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown") : - itk::ExceptionObject(file, line, message, loc) { } - }; + itk::ExceptionObject(file, line, message, loc) { } +}; template < class TImage, class TInternalImage = TImage > class ITK_EXPORT ImageSeriesFileReaderBase : public ImageListSource< TImage > { - public: - /** Standart typedefs */ - typedef ImageSeriesFileReaderBase Self; - typedef ImageListSource< TImage > Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Creation through object factory macro */ - itkNewMacro(Self); - /** Runtime informations macro */ - itkTypeMacro(ImageSeriesFileReaderBase,ImageListSource); - - typedef TImage OutputImageType; - typedef typename OutputImageType::Pointer OutputImagePointerType; - typedef typename OutputImageType::InternalPixelType PixelType; - typedef typename OutputImageType::ValueType ValueType; - typedef typename OutputImageType::IndexType IndexType; - typedef typename OutputImageType::SizeType SizeType; - typedef typename OutputImageType::RegionType RegionType; - - typedef ImageList<OutputImageType> OutputImageListType; - typedef typename OutputImageListType::Pointer OutputImageListPointerType; - typedef typename OutputImageListType::ConstPointer OutputImageListConstPointerType; - - typedef TInternalImage InternalImageType; - typedef typename InternalImageType::Pointer InternalImagePointerType; - typedef typename InternalImageType::InternalPixelType InternalPixelType; - typedef typename InternalImageType::ValueType InternalValueType; - typedef typename InternalImageType::IndexType InternalIndexType; - typedef typename InternalImageType::SizeType InternalSizeType; - typedef typename InternalImageType::RegionType InternalRegionType; - - typedef ImageFileReader< InternalImageType > ReaderType; - typedef typename ReaderType::Pointer ReaderPointerType; - - typedef ObjectList< ReaderType > ReaderListType; - typedef typename ReaderListType::Pointer ReaderListPointerType; - - /** Get the file to be read */ - itkGetStringMacro(FileName); - /** - * Set the file to be read. Once the Filename is set, ReadMeatFile is called in order to get - * the number of image files to be read, the images file names, the band and region - * selection - */ - virtual void SetFileName ( const std::string & file ); - virtual void SetFileName ( const char * file ); - - /** Get the readers */ - itkGetObjectMacro(ImageFileReaderList,ReaderListType); - - /** Get the output list */ - virtual unsigned int GetNumberOfOutputs () const - { - return m_ListOfFileNames.size(); - } - virtual OutputImageListType * GetOutput(void); - virtual OutputImageType * GetOutput( unsigned int idx ); - - /** Performs selective file extraction */ - virtual OutputImageListType * GenerateOutput (void); - virtual OutputImageType * GenerateOutput ( unsigned int idx ); - - protected: - ImageSeriesFileReaderBase(); - virtual ~ImageSeriesFileReaderBase () { } - - enum FileType { kFileName = 0, kImageFileName, kAnyFileName }; - /** - * Test files. - * If the filename to test is an imageFileName, the file name may be modified in - * order to add the appropriated path - */ - virtual void TestFileExistanceAndReadability( std::string & file, FileType fileType ); - virtual void TestBandSelection( std::vector<unsigned int> & bands ) { } - - virtual void GenerateData ( void ); - - /** GenerateData - * This method will be specialised if template definitions follow: - * - TImage is a VectorImage - * - TImage is an Image and TInteranalImage is a VectorImage - * - TImage and TInternalImage are of Image type. - */ - virtual void GenerateData ( unsigned int idx ); - - /** - * Read the MetaFile and test its effectiveness once inputFileName is set. - */ - virtual void ReadMetaFile (); - /** - * Once MetaFile is read, allocation of lists are performed in SetFileName. - * This allows specific (or global) initialisation in the GenerateData methods, - * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). - */ - virtual void AllocateListOfComponents ( void ); - - /** PrintSelf method */ - virtual void PrintSelf ( std::ostream& os, itk::Indent indent ) const; - - std::string m_FileName; - OutputImageListPointerType m_OutputList; - - std::vector< std::string > m_ListOfFileNames; - std::vector< std::vector<unsigned int> > m_ListOfBandSelection; - std::vector< InternalRegionType > m_ListOfRegionSelection; - - ReaderListPointerType m_ImageFileReaderList; - - private: - ImageSeriesFileReaderBase ( const Self & ); - void operator= ( const Self & ); +public: + /** Standart typedefs */ + typedef ImageSeriesFileReaderBase Self; + typedef ImageListSource< TImage > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Runtime informations macro */ + itkTypeMacro(ImageSeriesFileReaderBase,ImageListSource); + + typedef TImage OutputImageType; + typedef typename OutputImageType::Pointer OutputImagePointerType; + typedef typename OutputImageType::InternalPixelType PixelType; + typedef typename OutputImageType::ValueType ValueType; + typedef typename OutputImageType::IndexType IndexType; + typedef typename OutputImageType::SizeType SizeType; + typedef typename OutputImageType::RegionType RegionType; + + typedef ImageList<OutputImageType> OutputImageListType; + typedef typename OutputImageListType::Pointer OutputImageListPointerType; + typedef typename OutputImageListType::ConstPointer OutputImageListConstPointerType; + + typedef TInternalImage InternalImageType; + typedef typename InternalImageType::Pointer InternalImagePointerType; + typedef typename InternalImageType::InternalPixelType InternalPixelType; + typedef typename InternalImageType::ValueType InternalValueType; + typedef typename InternalImageType::IndexType InternalIndexType; + typedef typename InternalImageType::SizeType InternalSizeType; + typedef typename InternalImageType::RegionType InternalRegionType; + + typedef ImageFileReader< InternalImageType > ReaderType; + typedef typename ReaderType::Pointer ReaderPointerType; + + typedef ObjectList< ReaderType > ReaderListType; + typedef typename ReaderListType::Pointer ReaderListPointerType; + + /** Get the file to be read */ + itkGetStringMacro(FileName); + /** + * Set the file to be read. Once the Filename is set, ReadMeatFile is called in order to get + * the number of image files to be read, the images file names, the band and region + * selection + */ + virtual void SetFileName ( const std::string & file ); + virtual void SetFileName ( const char * file ); + + /** Get the readers */ + itkGetObjectMacro(ImageFileReaderList,ReaderListType); + + /** Get the output list */ + virtual unsigned int GetNumberOfOutputs () const + { + return m_ListOfFileNames.size(); + } + virtual OutputImageListType * GetOutput(void); + virtual OutputImageType * GetOutput( unsigned int idx ); + + /** Performs selective file extraction */ + virtual OutputImageListType * GenerateOutput (void); + virtual OutputImageType * GenerateOutput ( unsigned int idx ); + +protected: + ImageSeriesFileReaderBase(); + virtual ~ImageSeriesFileReaderBase () { } + + enum FileType { kFileName = 0, kImageFileName, kAnyFileName }; + /** + * Test files. + * If the filename to test is an imageFileName, the file name may be modified in + * order to add the appropriated path + */ + virtual void TestFileExistanceAndReadability( std::string & file, FileType fileType ); + virtual void TestBandSelection( std::vector<unsigned int> & bands ) { } + + virtual void GenerateData ( void ); + + /** GenerateData + * This method will be specialised if template definitions follow: + * - TImage is a VectorImage + * - TImage is an Image and TInteranalImage is a VectorImage + * - TImage and TInternalImage are of Image type. + */ + virtual void GenerateData ( unsigned int idx ); + + /** + * Read the MetaFile and test its effectiveness once inputFileName is set. + */ + virtual void ReadMetaFile (); + /** + * Once MetaFile is read, allocation of lists are performed in SetFileName. + * This allows specific (or global) initialisation in the GenerateData methods, + * that the user may invoke throught GenerateOutput() or GenerateOutput( idx ). + */ + virtual void AllocateListOfComponents ( void ); + + /** PrintSelf method */ + virtual void PrintSelf ( std::ostream& os, itk::Indent indent ) const; + + std::string m_FileName; + OutputImageListPointerType m_OutputList; + + std::vector< std::string > m_ListOfFileNames; + std::vector< std::vector<unsigned int> > m_ListOfBandSelection; + std::vector< InternalRegionType > m_ListOfRegionSelection; + + ReaderListPointerType m_ImageFileReaderList; + +private: + ImageSeriesFileReaderBase ( const Self & ); + void operator= ( const Self & ); }; // end of class } // end of namespace otb diff --git a/Code/IO/otbImageSeriesFileReaderBase.txx b/Code/IO/otbImageSeriesFileReaderBase.txx index 2319754648..7e68d87e21 100644 --- a/Code/IO/otbImageSeriesFileReaderBase.txx +++ b/Code/IO/otbImageSeriesFileReaderBase.txx @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,10 +23,11 @@ #include "otbImageSeriesFileReaderBase.h" -namespace otb { +namespace otb +{ template < class TImage, class TInternalImage > -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::ImageSeriesFileReaderBase () { m_OutputList = OutputImageListType::New(); @@ -35,7 +36,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::SetFileName ( const std::string & file ) { return SetFileName( file.c_str() ); @@ -43,10 +44,10 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::SetFileName ( const char * file ) { - if ( file && ( file == m_FileName ) ) + if ( file && ( file == m_FileName ) ) return; if ( file ) @@ -63,7 +64,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > template < class TImage, class TInternalImage > typename ImageSeriesFileReaderBase< TImage, TInternalImage >::OutputImageListType * -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::GetOutput () { if ( this->GetNumberOfOutputs() < 1 ) @@ -74,7 +75,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > template < class TImage, class TInternalImage > typename ImageSeriesFileReaderBase< TImage, TInternalImage >::OutputImageType * -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::GetOutput ( unsigned int idx ) { if ( this->GetNumberOfOutputs() < 1 ) @@ -88,7 +89,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::ReadMetaFile () { m_ListOfFileNames.clear(); @@ -100,9 +101,9 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > std::string aLine; std::ifstream inputFile ( m_FileName.c_str(), std::ios_base::in ); - inputFile >> aLine; - if ( aLine != "ENVI" ) - { + inputFile >> aLine; + if ( aLine != "ENVI" ) + { inputFile.close(); itk::OStringStream msg; msg << "The file " << m_FileName << " is not a \"ENVI META FILE\" format\n"; @@ -112,8 +113,8 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > } inputFile >> aLine; - if ( aLine != "META" ) - { + if ( aLine != "META" ) + { inputFile.close(); itk::OStringStream msg; msg << "The file " << m_FileName << " is not a \"ENVI META FILE\" format\n"; @@ -121,10 +122,10 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > throw e; return; } - + inputFile >> aLine; - if ( aLine != "FILE" ) - { + if ( aLine != "FILE" ) + { inputFile.close(); itk::OStringStream msg; msg << "The file " << m_FileName << " is not a \"ENVI META FILE\" format\n"; @@ -134,21 +135,25 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > } while ( 1 ) - { - /* + { + /* * Reading the filenames */ - do { - inputFile >> aLine; - //std::cerr << "-> '" << aLine << "'\n"; - } while ( aLine != "File" && inputFile.good() ); + do + { + inputFile >> aLine; + //std::cerr << "-> '" << aLine << "'\n"; + } + while ( aLine != "File" && inputFile.good() ); - if ( inputFile.good() ) + if ( inputFile.good() ) { - do { + do + { inputFile >> aLine; //std::cerr << "--> '" << aLine << "'\n"; - } while ( aLine != ":" && inputFile.good() ); + } + while ( aLine != ":" && inputFile.good() ); if ( !inputFile.good() ) { @@ -162,26 +167,28 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > } } else - return; // normal exit - + return; // normal exit + inputFile >> aLine; std::cerr << "-> " << aLine << "\n"; // Get the Image fileName - // The test may modify image file name to add the path + // The test may modify image file name to add the path // Or throw an exception when not found nor readable TestFileExistanceAndReadability( aLine, kImageFileName ); m_ListOfFileNames.push_back( aLine ); - std::string imageFileName = aLine; + std::string imageFileName = aLine; /* * Reading the Band number */ - do { - inputFile >> aLine; - //std::cerr << "-> '" << aLine << "'\n"; - } while ( aLine != "Bands:" && inputFile.good() ); + do + { + inputFile >> aLine; + //std::cerr << "-> '" << aLine << "'\n"; + } + while ( aLine != "Bands:" && inputFile.good() ); if ( !inputFile.good() ) { @@ -223,33 +230,38 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > } // Storing band selection - try { - TestBandSelection( bands ); - } - catch ( ImageSeriesFileReaderException & e ) - { - itk::OStringStream msg; - msg << e.GetDescription(); - msg << "Image FileName : " << imageFileName << "\n"; - e.SetDescription( msg.str().c_str() ); - throw e; - } - m_ListOfBandSelection.push_back( bands ); + try + { + TestBandSelection( bands ); + } + catch ( ImageSeriesFileReaderException & e ) + { + itk::OStringStream msg; + msg << e.GetDescription(); + msg << "Image FileName : " << imageFileName << "\n"; + e.SetDescription( msg.str().c_str() ); + throw e; + } + m_ListOfBandSelection.push_back( bands ); /* * Reading the Region selection */ - do { - inputFile >> aLine; - //std::cerr << "-> '" << aLine << "'\n"; - } while ( aLine != "Dims" && inputFile.good() ); + do + { + inputFile >> aLine; + //std::cerr << "-> '" << aLine << "'\n"; + } + while ( aLine != "Dims" && inputFile.good() ); - if ( inputFile.good() ) + if ( inputFile.good() ) { - do { + do + { inputFile >> aLine; //std::cerr << "--> '" << aLine << "'\n"; - } while ( aLine != ":" && inputFile.good() ); + } + while ( aLine != ":" && inputFile.good() ); if ( !inputFile.good() ) { @@ -282,7 +294,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > IndexType index; index[0] = beg_col - 1; - index[1] = beg_line - 1; + index[1] = beg_line - 1; SizeType size; size[0] = end_col - beg_col; @@ -298,7 +310,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::AllocateListOfComponents () { for ( unsigned int i = 0; i < GetNumberOfOutputs(); i++ ) @@ -309,23 +321,23 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > } /** - * GenerateData + * GenerateData */ template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::GenerateData( unsigned int idx ) { - itk::OStringStream msg; - msg << "Something wrong... Check the template definition of this class in the program...\n"; - msg << "\"ENVI META FILE\" FileName: " << m_FileName << "\n"; - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); - throw e; + itk::OStringStream msg; + msg << "Something wrong... Check the template definition of this class in the program...\n"; + msg << "\"ENVI META FILE\" FileName: " << m_FileName << "\n"; + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); + throw e; } template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::GenerateData( ) { for ( unsigned int i = 0; i < GetNumberOfOutputs(); i++ ) @@ -337,26 +349,26 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > */ template < class TImage, class TInternalImage > typename ImageSeriesFileReaderBase< TImage, TInternalImage >::OutputImageListType * -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::GenerateOutput() { - this->Update(); - return this->GetOutput(); + this->Update(); + return this->GetOutput(); } template < class TImage, class TInternalImage > typename ImageSeriesFileReaderBase< TImage, TInternalImage >::OutputImageType * -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::GenerateOutput( unsigned int idx ) { - this->GenerateData( idx ); - return this->GetOutput( idx ); + this->GenerateData( idx ); + return this->GetOutput( idx ); } template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::PrintSelf ( std::ostream& os, itk::Indent indent ) const { Superclass::PrintSelf(os, indent); @@ -364,38 +376,38 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > if ( m_ListOfFileNames.size() > 0 ) { - std::vector< std::vector< unsigned int > >::const_iterator bandSelection = m_ListOfBandSelection.begin(); + std::vector< std::vector< unsigned int > >::const_iterator bandSelection = m_ListOfBandSelection.begin(); os << indent << "Image File(s) to be read\n"; for ( unsigned int i = 0; i < GetNumberOfOutputs(); ++i ) { os << indent << " " << "Filename : " << m_ListOfFileNames[i] << "\n"; - os << indent << " " << "RegionSelection: Index( " - << m_ListOfRegionSelection[i].GetIndex()[0] << ", " - << m_ListOfRegionSelection[i].GetIndex()[1] << ") Size( " - << m_ListOfRegionSelection[i].GetSize()[0] << ", " - << m_ListOfRegionSelection[i].GetSize()[1] << ")\n"; + os << indent << " " << "RegionSelection: Index( " + << m_ListOfRegionSelection[i].GetIndex()[0] << ", " + << m_ListOfRegionSelection[i].GetIndex()[1] << ") Size( " + << m_ListOfRegionSelection[i].GetSize()[0] << ", " + << m_ListOfRegionSelection[i].GetSize()[1] << ")\n"; os << indent << " " << "BandSelection : "; for ( std::vector<unsigned int>::const_iterator bd = (*bandSelection).begin(); - bd != (*bandSelection).end(); - ++bd ) + bd != (*bandSelection).end(); + ++bd ) { os << *bd << " "; } os << "\n"; - ++bandSelection; + ++bandSelection; } } } template < class TImage, class TInternalImage > void -ImageSeriesFileReaderBase< TImage, TInternalImage > +ImageSeriesFileReaderBase< TImage, TInternalImage > ::TestFileExistanceAndReadability ( std::string & file, FileType fileType ) { // Test if the file exists. - if( !itksys::SystemTools::FileExists( file.c_str() ) ) + if ( !itksys::SystemTools::FileExists( file.c_str() ) ) { if ( fileType != kImageFileName ) { @@ -417,7 +429,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > fullPath.push_back( "/" ); fullPath.push_back( file ); - std::string fullFileName = itksys::SystemTools::JoinPath( fullPath ); + std::string fullFileName = itksys::SystemTools::JoinPath( fullPath ); if ( !itksys::SystemTools::FileExists( fullFileName.c_str() ) ) { @@ -426,7 +438,7 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > msg << "The image file doesn't exist. \n"; msg << "ImageFileName = " << file << "\n"; msg << "tested path = " << itksys::SystemTools::GetFilenamePath( m_FileName ) << "\n"; - msg << "Other Tested File = " << fullFileName << "\n"; + msg << "Other Tested File = " << fullFileName << "\n"; e.SetDescription( msg.str().c_str() ); throw e; return; @@ -442,12 +454,12 @@ ImageSeriesFileReaderBase< TImage, TInternalImage > // Test if the file can be open for reading access. std::ifstream readTester; readTester.open( file.c_str() ); - if( readTester.fail() ) + if ( readTester.fail() ) { readTester.close(); itk::OStringStream msg; msg << "The file couldn't be opened for reading. " - << std::endl << "Filename: " << file << std::endl; + << std::endl << "Filename: " << file << std::endl; ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION); throw e; return; diff --git a/Code/Learning/otbSVMClassifier.txx b/Code/Learning/otbSVMClassifier.txx index 5643f7a13b..53f14768a0 100644 --- a/Code/Learning/otbSVMClassifier.txx +++ b/Code/Learning/otbSVMClassifier.txx @@ -55,10 +55,10 @@ void SVMClassifier< TSample, TLabel > ::GenerateData() { - if(m_Model->GetNumberOfSupportVectors() == 0) - { + if (m_Model->GetNumberOfSupportVectors() == 0) + { itkExceptionMacro(<<"SVM model does not contain any support vector, can not perform classification."); - } + } m_Output->SetSample(this->GetSample()); diff --git a/Code/MultiScale/otbHaarOperator.h b/Code/MultiScale/otbHaarOperator.h index 57e80af94f..6ac0587efd 100644 --- a/Code/MultiScale/otbHaarOperator.h +++ b/Code/MultiScale/otbHaarOperator.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,16 +22,17 @@ #include "otbWaveletOperator.h" -namespace otb { +namespace otb +{ /** * \class LowPassHaarOperator * * \brief A NeighborhoodOperator for performing a Haar based filtering * at a pixel location. - * - * LowPassHaarOperator is a NeighborhoodOperator that should be applied to a - * NeighborhoodIterator using the NeighborhoodInnerProduct method. + * + * LowPassHaarOperator is a NeighborhoodOperator that should be applied to a + * NeighborhoodIterator using the NeighborhoodInnerProduct method. * The Haar Operator is defiend in 1D as \$ H(z) = ( 1 + z^{-1} ) / 2 \$. * In N dimensions, the operator is directional * @@ -40,13 +41,13 @@ namespace otb { * \sa Neighborhood * \sa ForwardDifferenceOperator * \sa BackwardDifferenceOperator - * + * * \ingroup Operators */ template<class TPixel, unsigned int VDimension, - class TAllocator = itk::NeighborhoodAllocator< TPixel > > +class TAllocator = itk::NeighborhoodAllocator< TPixel > > class ITK_EXPORT LowPassHaarOperator - : public WaveletOperator<TPixel, VDimension, TAllocator> + : public WaveletOperator<TPixel, VDimension, TAllocator> { public: /** Standard typedefs */ @@ -54,15 +55,15 @@ public: typedef WaveletOperator<TPixel, VDimension, TAllocator> Superclass; itkTypeMacro(LowPassHaarOperator, WaveletOperator); - - LowPassHaarOperator() - { + + LowPassHaarOperator() + { this->SetRadius(1); - this->CreateToRadius(1); + this->CreateToRadius(1); } LowPassHaarOperator(const Self& other) - : WaveletOperator<TPixel, VDimension, TAllocator>(other) + : WaveletOperator<TPixel, VDimension, TAllocator>(other) { /* ... */ } @@ -78,8 +79,8 @@ public: /** * Prints some debugging information */ - virtual void PrintSelf(std::ostream &os, itk::Indent i) const - { + virtual void PrintSelf(std::ostream &os, itk::Indent i) const + { Superclass::PrintSelf(os, i.GetNextIndent()); os << i << "LowPassHaarOperator {this=" << this << "}" << std::endl; } @@ -99,19 +100,19 @@ protected: { CoefficientVector coeff; // stands for z^{-1} - coeff.push_back(0.5); + coeff.push_back(0.5); // stands for z^0 coeff.push_back(0.5); // stands for z^1 - coeff.push_back(0.0); + coeff.push_back(0.0); return Superclass::UpSamplingCoefficients( coeff ); } /** Arranges coefficients spatially in the memory buffer. */ void Fill(const CoefficientVector& coeff) - { - this->FillCenteredDirectional(coeff); + { + this->FillCenteredDirectional(coeff); } }; @@ -120,9 +121,9 @@ protected: * * \brief A NeighborhoodOperator for performing a Haar based filtering * at a pixel location. - * - * HighPassHaarOperator is a NeighborhoodOperator that should be applied a - * NeighborhoodIterator using the NeighborhoodInnerProduct method. + * + * HighPassHaarOperator is a NeighborhoodOperator that should be applied a + * NeighborhoodIterator using the NeighborhoodInnerProduct method. * The Haar Operator is defiend in 1D as \$ G(z) = ( 1 - z^{-1} ) / 2 \$. * In N dimensions, the operator is directional * @@ -131,13 +132,13 @@ protected: * \sa Neighborhood * \sa ForwardDifferenceOperator * \sa BackwardDifferenceOperator - * + * * \ingroup Operators */ template<class TPixel, unsigned int VDimension, - class TAllocator = itk::NeighborhoodAllocator< TPixel > > +class TAllocator = itk::NeighborhoodAllocator< TPixel > > class ITK_EXPORT HighPassHaarOperator - : public WaveletOperator<TPixel, VDimension, TAllocator> + : public WaveletOperator<TPixel, VDimension, TAllocator> { public: /** Standard typedefs */ @@ -145,15 +146,15 @@ public: typedef WaveletOperator<TPixel, VDimension, TAllocator> Superclass; itkTypeMacro(HighPassHaarOperator, WaveletOperator); - - HighPassHaarOperator() - { + + HighPassHaarOperator() + { this->SetRadius(1); - this->CreateToRadius(1); + this->CreateToRadius(1); } HighPassHaarOperator(const Self& other) - : WaveletOperator<TPixel, VDimension, TAllocator>(other) + : WaveletOperator<TPixel, VDimension, TAllocator>(other) { /* ... */ } @@ -169,8 +170,8 @@ public: /** * Prints some debugging information */ - virtual void PrintSelf(std::ostream &os, itk::Indent i) const - { + virtual void PrintSelf(std::ostream &os, itk::Indent i) const + { Superclass::PrintSelf(os, i.GetNextIndent()); os << i << "HighPassHaarOperator {this=" << this << "}" << std::endl; } @@ -189,17 +190,17 @@ protected: CoefficientVector GenerateCoefficients() { CoefficientVector coeff; - coeff.push_back(-0.5); - coeff.push_back(0.5); - coeff.push_back(0.0); + coeff.push_back(-0.5); + coeff.push_back(0.5); + coeff.push_back(0.0); return Superclass::UpSamplingCoefficients( coeff ); } /** Arranges coefficients spatially in the memory buffer. */ void Fill(const CoefficientVector& coeff) - { - this->FillCenteredDirectional(coeff); + { + this->FillCenteredDirectional(coeff); } }; diff --git a/Code/MultiScale/otbStationaryFilterBank.h b/Code/MultiScale/otbStationaryFilterBank.h index d8be7b3812..8c7ad86f66 100644 --- a/Code/MultiScale/otbStationaryFilterBank.h +++ b/Code/MultiScale/otbStationaryFilterBank.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -28,13 +28,14 @@ #include "itkNeighborhoodAlgorithm.h" #include "itkNeighborhoodInnerProduct.h" -namespace otb { +namespace otb +{ /** \class StationaryFilterBank * \brief One level stationary wavelet transform * * This implementation performs a low-pass / high-pass wavelet transformation - * of an image. The wavelet transformation is defined by a inner product + * of an image. The wavelet transformation is defined by a inner product * (ie. convolution-like operation). * * the inner operator are supposed to be defined through 1D filters. Then, the @@ -62,7 +63,7 @@ namespace otb { * Dim (n-1) Dim (n-2) Dim (n-3) ... Dim 1 Dim 0 * * -> x_(n-1) x_(n-2) x_(n-3) x_1 x_0 - * + * * * * \sa LowPassHaarOperator @@ -74,35 +75,35 @@ namespace otb { */ template < class TInputImage, class TOutputImage, class TLowPassOperator, class THighPassOperator > class ITK_EXPORT StationaryFilterBank - : public itk::ImageToImageFilter< TInputImage, TOutputImage > + : public itk::ImageToImageFilter< TInputImage, TOutputImage > { public: /** Standard typedefs */ typedef StationaryFilterBank Self; typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass; typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef itk::SmartPointer<const Self> ConstPointer; - /** Type macro */ - itkNewMacro(Self); + /** Type macro */ + itkNewMacro(Self); - /** Creation through object factory macro */ - itkTypeMacro(StationaryFilterBank,ImageToImageFilter); + /** Creation through object factory macro */ + itkTypeMacro(StationaryFilterBank,ImageToImageFilter); /** Template parameters typedefs */ typedef TInputImage InputImageType; - typedef typename InputImageType::Pointer InputImagePointerType; - typedef typename InputImageType::RegionType InputImageRegionType; - typedef typename InputImageType::SizeType InputSizeType; - typedef typename InputImageType::IndexType InputIndexType; - typedef typename InputImageType::PixelType InputPixelType; + typedef typename InputImageType::Pointer InputImagePointerType; + typedef typename InputImageType::RegionType InputImageRegionType; + typedef typename InputImageType::SizeType InputSizeType; + typedef typename InputImageType::IndexType InputIndexType; + typedef typename InputImageType::PixelType InputPixelType; typedef TOutputImage OutputImageType; - typedef typename OutputImageType::Pointer OutputImagePointerType; + typedef typename OutputImageType::Pointer OutputImagePointerType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename OutputImageType::SizeType OutputSizeType; typedef typename OutputImageType::IndexType OutputIndexType; - typedef typename OutputImageType::PixelType OutputPixelType; + typedef typename OutputImageType::PixelType OutputPixelType; typedef TLowPassOperator LowPassOperatorType; typedef THighPassOperator HighPassOperatorType; @@ -111,14 +112,14 @@ public: typedef itk::ConstNeighborhoodIterator< OutputImageType > NeighborhoodIteratorType; typedef itk::NeighborhoodInnerProduct< OutputImageType > InnerProductType; typedef itk::ImageRegionIterator< OutputImageType > IteratorType; - typedef typename itk::NeighborhoodAlgorithm - ::ImageBoundaryFacesCalculator< OutputImageType > FaceCalculatorType; + typedef typename itk::NeighborhoodAlgorithm + ::ImageBoundaryFacesCalculator< OutputImageType > FaceCalculatorType; typedef typename FaceCalculatorType::FaceListType FaceListType; typedef typename FaceListType::iterator FaceListIterator; /** Dimension */ - itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension); - itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension); + itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension); + itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension); /** * Set/Get the level of up sampling of the filter used in the A-trou algorithm @@ -135,12 +136,12 @@ protected: /** Specific case applied on the input image */ virtual void ThreadedGenerateData ( itk::ProgressReporter & reporter, - const OutputImageRegionType& outputRegionForThread, int threadId ); + const OutputImageRegionType& outputRegionForThread, int threadId ); /** Iterative call to the filter bank at each dimension */ - virtual void ThreadedGenerateData ( unsigned int idx, unsigned int direction, - itk::ProgressReporter & reporter, - const OutputImageRegionType& outputRegionForThread, int threadId ); + virtual void ThreadedGenerateData ( unsigned int idx, unsigned int direction, + itk::ProgressReporter & reporter, + const OutputImageRegionType& outputRegionForThread, int threadId ); unsigned int m_UpSampleFactor; @@ -149,7 +150,7 @@ private: void operator=( const Self & ); }; // end of class - + } // end of namespace otb #ifndef OTB_MANUAL_INSTANTIATION diff --git a/Code/MultiScale/otbStationaryFilterBank.txx b/Code/MultiScale/otbStationaryFilterBank.txx index 230913379a..1796e3a737 100644 --- a/Code/MultiScale/otbStationaryFilterBank.txx +++ b/Code/MultiScale/otbStationaryFilterBank.txx @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -27,7 +27,8 @@ #include "itkZeroFluxNeumannBoundaryCondition.h" #include "itkProgressReporter.h" -namespace otb { +namespace otb +{ template < class TInputImage, class TOutputImage, class TLowPassOperator, class THighPassOperator > StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOperator > @@ -37,7 +38,7 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper unsigned int numOfOutput = 1<<InputImageType::ImageDimension; - this->SetNumberOfOutputs( numOfOutput ); + this->SetNumberOfOutputs( numOfOutput ); for ( unsigned i = 1; i < numOfOutput; i++ ) { this->SetNthOutput(i,OutputImageType::New()); @@ -51,8 +52,8 @@ void StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOperator > ::ThreadedGenerateData ( const OutputImageRegionType& outputRegionForThread, int threadId ) { - itk::ProgressReporter reporter ( this, threadId, - outputRegionForThread.GetNumberOfPixels() * this->GetNumberOfOutputs() ); + itk::ProgressReporter reporter ( this, threadId, + outputRegionForThread.GetNumberOfPixels() * this->GetNumberOfOutputs() ); ThreadedGenerateData( reporter, outputRegionForThread, threadId ); } @@ -60,7 +61,7 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper template < class TInputImage, class TOutputImage, class TLowPassOperator, class THighPassOperator > void StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOperator > -::ThreadedGenerateData +::ThreadedGenerateData ( itk::ProgressReporter & reporter, const OutputImageRegionType& outputRegionForThread, int threadId ) { @@ -79,7 +80,7 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper if ( outputHighPass == 0 ) { itk::OStringStream msg; - msg << "Sortie 1<<" << idx << " = " << (1<<idx) << " nulle\n"; + msg << "Sortie 1<<" << idx << " = " << (1<<idx) << " nulle\n"; msg << "Nombre de sortie attendue " << this->GetNumberOfOutputs() << "\n"; throw itk::ExceptionObject( __FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION ); } @@ -91,7 +92,7 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper typedef typename InputFaceListType::iterator InputFaceListIterator; InputInnerProductType innerProduct; - InputFaceCalculatorType faceCalculator; + InputFaceCalculatorType faceCalculator; InputFaceListType faceList; // High pass part calculation @@ -107,8 +108,8 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper InputNeighborhoodIteratorType it ( highPassOperator.GetRadius(), input, *faceIt ); IteratorType out ( outputHighPass, *faceIt ); - for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) - { + for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) + { out.Set( innerProduct( it, highPassOperator ) ); reporter.CompletedPixel(); } @@ -127,8 +128,8 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper InputNeighborhoodIteratorType it ( lowPassOperator.GetRadius(), input, *faceIt ); IteratorType out ( outputLowPass, *faceIt ); - for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) - { + for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) + { out.Set( innerProduct( it, lowPassOperator ) ); reporter.CompletedPixel(); } @@ -144,7 +145,7 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper template < class TInputImage, class TOutputImage, class TLowPassOperator, class THighPassOperator > void StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOperator > -::ThreadedGenerateData +::ThreadedGenerateData ( unsigned int idx, unsigned int direction, itk::ProgressReporter & reporter, const OutputImageRegionType& outputRegionForThread, int threadId ) { @@ -156,7 +157,7 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper outputLowPass->Allocate(); InnerProductType innerProduct; - FaceCalculatorType faceCalculator; + FaceCalculatorType faceCalculator; FaceListType faceList; // High pass part calculation @@ -172,8 +173,8 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper NeighborhoodIteratorType it ( highPassOperator.GetRadius(), input, *faceIt ); IteratorType out ( outputHighPass, *faceIt ); - for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) - { + for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) + { out.Set( innerProduct( it, highPassOperator ) ); reporter.CompletedPixel(); } @@ -192,8 +193,8 @@ StationaryFilterBank< TInputImage, TOutputImage, TLowPassOperator, THighPassOper NeighborhoodIteratorType it ( lowPassOperator.GetRadius(), input, *faceIt ); IteratorType out ( outputLowPass, *faceIt ); - for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) - { + for ( it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out ) + { out.Set( innerProduct( it, lowPassOperator ) ); reporter.CompletedPixel(); } diff --git a/Code/MultiScale/otbWPCost.h b/Code/MultiScale/otbWPCost.h index d60982cbc1..876a8ab20c 100644 --- a/Code/MultiScale/otbWPCost.h +++ b/Code/MultiScale/otbWPCost.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -24,32 +24,33 @@ #include "itkObject.h" #include "itkMacro.h" -namespace otb { +namespace otb +{ /** \class FullyDecomposedWaveletPacketCost * \brief Cost evaluation to be used into the Wavelet Packet decomposition class. * - * This class implements the criteria to perform fully decomposed wavelet packet. + * This class implements the criteria to perform fully decomposed wavelet packet. * It is based on the depth of the decomposition only... * * \sa WaveletPacketForwardTransform */ template < class TImage > class ITK_EXPORT FullyDecomposedWaveletPacketCost - : public itk::Object + : public itk::Object { public: /** Standard typedefs */ typedef FullyDecomposedWaveletPacketCost Self; typedef itk::Object Superclass; typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef itk::SmartPointer<const Self> ConstPointer; - /** Type macro */ - itkNewMacro(Self); + /** Type macro */ + itkNewMacro(Self); - /** Creation through object factory macro */ - itkTypeMacro(FullyDecomposedWaveletPacketCost,Object); + /** Creation through object factory macro */ + itkTypeMacro(FullyDecomposedWaveletPacketCost,Object); typedef TImage ImageType; @@ -75,7 +76,7 @@ private: FullyDecomposedWaveletPacketCost ( const Self & ); // not implemented void operator= ( const Self & ); -}; // end of class +}; // end of class } // end of namespace otb diff --git a/Code/MultiScale/otbWaveletForwardTransform.h b/Code/MultiScale/otbWaveletForwardTransform.h index 3319c5c6ff..8d01740861 100644 --- a/Code/MultiScale/otbWaveletForwardTransform.h +++ b/Code/MultiScale/otbWaveletForwardTransform.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,7 +23,8 @@ #include "itkImageToImageFilter.h" -namespace otb { +namespace otb +{ /** \class WaveletForwardTransform * \brief Wavelet transformation framework @@ -31,13 +32,13 @@ namespace otb { * This class defines the Wavelet Packet transformation of an image * by using a (templated) elementary wavelet transform. * - * Here the number of decomposition is given. The output is then given + * Here the number of decomposition is given. The output is then given * in the GetOutputs() array. * * Output image organization depends on the number of Dim on the image - * In the OuputList, the first image is always the low passed one. Next, + * In the OuputList, the first image is always the low passed one. Next, * follow the high Passed images of the lowest decomposition (ask - * GetFilter(0)->GetNumberOfOutputs() to know the length) and so on until + * GetFilter(0)->GetNumberOfOutputs() to know the length) and so on until * the high passed images of the highest decomposition. * * \sa StationaryFilterBank @@ -46,20 +47,20 @@ namespace otb { */ template < class TInputImage, class TOutputImage, class TFilter > class ITK_EXPORT WaveletForwardTransform - : public itk::ImageToImageFilter< TInputImage, TOutputImage > + : public itk::ImageToImageFilter< TInputImage, TOutputImage > { public: /** Standard typedefs */ typedef WaveletForwardTransform Self; typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass; typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef itk::SmartPointer<const Self> ConstPointer; - /** Type macro */ - itkNewMacro(Self); + /** Type macro */ + itkNewMacro(Self); - /** Creation through object factory macro */ - itkTypeMacro(WaveletForwardTransform,ImageToImageFilter); + /** Creation through object factory macro */ + itkTypeMacro(WaveletForwardTransform,ImageToImageFilter); typedef TInputImage InputImageType; typedef typename InputImageType::Pointer InputImagePointer; diff --git a/Code/MultiScale/otbWaveletForwardTransform.txx b/Code/MultiScale/otbWaveletForwardTransform.txx index 99c1115ca0..9abaa9c888 100644 --- a/Code/MultiScale/otbWaveletForwardTransform.txx +++ b/Code/MultiScale/otbWaveletForwardTransform.txx @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,7 +23,8 @@ #include "otbWaveletForwardTransform.h" -namespace otb { +namespace otb +{ template < class TInputImage, class TOutputImage, class TFilter > WaveletForwardTransform< TInputImage, TOutputImage, TFilter > @@ -56,7 +57,7 @@ WaveletForwardTransform< TInputImage, TOutputImage, TFilter > unsigned int idx = 0; GetFilter(0)->GraftNthOutput( 0, this->GetOutput(idx++) ); - + for ( unsigned int i = 0; i < this->GetNumberOfDecompositions(); i++ ) { for ( unsigned int j = 1; j < this->GetFilter(i)->GetNumberOfOutputs(); j++ ) @@ -90,7 +91,7 @@ WaveletForwardTransform< TInputImage, TOutputImage, TFilter > unsigned int subSampleFactor = 0; while ( nbDecomp > 0 ) - { + { /* std::cerr << "Doing Decomp " << nbDecomp << "\n"; std::cerr << "outputIdxForGraft = " << outputIdxForGraft << "\n"; @@ -128,7 +129,7 @@ WaveletForwardTransform< TInputImage, TOutputImage, TFilter > GetFilter(nbDecomp)->GraftNthOutput( idx, this->GetOutput( outputIdxForGraft-- ) ); if ( m_UseSubSampleImage == false ) - GetFilter(nbDecomp)->SetUpSampleFactor( ++subSampleFactor ); + GetFilter(nbDecomp)->SetUpSampleFactor( ++subSampleFactor ); GetFilter( nbDecomp )->Update(); diff --git a/Code/MultiScale/otbWaveletOperator.h b/Code/MultiScale/otbWaveletOperator.h index 40e9a1ff2d..cde282c710 100644 --- a/Code/MultiScale/otbWaveletOperator.h +++ b/Code/MultiScale/otbWaveletOperator.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,7 +23,8 @@ #include "itkExceptionObject.h" #include "itkNeighborhoodOperator.h" -namespace otb { +namespace otb +{ /** * \class WaveletOperator @@ -31,20 +32,20 @@ namespace otb { * \brief A NeighborhoodOperator wavelet base class * * This class is the mother class for any wavelet operator that requires - * "a-trou" approach for shift-invariant wavelet transform. This class has + * "a-trou" approach for shift-invariant wavelet transform. This class has * to be derived, it cannot be used directly. * * Any wavelet operator that inherits from WaveletOperator is to be used - * as a NeighborhoodOperator that should be applied to a + * as a NeighborhoodOperator that should be applied to a * NeighborhoodIterator using the NeighborhoodInnerProduct method. * * It is assumed that any wavelet is directional. * - * Set the level of up-sampling though SetUpSampleFactor() before calling - * CreateDirectional(). Each class that inherits from WaveletOperator has + * Set the level of up-sampling though SetUpSampleFactor() before calling + * CreateDirectional(). Each class that inherits from WaveletOperator has * to re-implement GenerateCoefficients(). It has to end by: * return this->UpSamplingCoefficients( coeff ) to perform the up-sampling - * + * * \sa LowPassHaarOperator * \sa HighPassHaarOperator * \sa NeighborhoodOperator @@ -53,9 +54,9 @@ namespace otb { * \ingroup Operators */ template<class TPixel, unsigned int VDimension, - class TAllocator = itk::NeighborhoodAllocator< TPixel > > +class TAllocator = itk::NeighborhoodAllocator< TPixel > > class ITK_EXPORT WaveletOperator - : public itk::NeighborhoodOperator<TPixel, VDimension, TAllocator> + : public itk::NeighborhoodOperator<TPixel, VDimension, TAllocator> { public: /** Standard typedefs */ @@ -65,13 +66,13 @@ public: itkTypeMacro(WaveletOperator,NeighborhoodOperator); /** Construction */ - WaveletOperator() + WaveletOperator() { m_UpSampleFactor = 0; } /** Construction by copy */ - WaveletOperator( const Self & other ) - : itk::NeighborhoodOperator<TPixel, VDimension, TAllocator> (other) + WaveletOperator( const Self & other ) + : itk::NeighborhoodOperator<TPixel, VDimension, TAllocator> (other) { m_UpSampleFactor = other.GetUpSampleFactor(); } @@ -87,8 +88,8 @@ public: /** * Prints some debugging information */ - virtual void PrintSelf(std::ostream &os, itk::Indent i) const - { + virtual void PrintSelf(std::ostream &os, itk::Indent i) const + { Superclass::PrintSelf(os, i.GetNextIndent()); os << i << "Up-Sampling factor " << this->m_UpSampleFactor << "\n"; } @@ -96,7 +97,7 @@ public: /** * Set/Get the level of up sampling of the filter */ - unsigned int GetUpSampleFactor () const + unsigned int GetUpSampleFactor () const { return this->m_UpSampleFactor; } @@ -113,11 +114,11 @@ protected: typedef typename Superclass::CoefficientVector CoefficientVector; typedef typename Superclass::PixelType PixelType; - /** + /** * Perform the "a-trou" algorithm for shift-invariant transformation. * It transforms the filter \$ H(z) \$ into \$ H(z^2) \$. */ - CoefficientVector UpSamplingCoefficients ( CoefficientVector & coeff ) + CoefficientVector UpSamplingCoefficients ( CoefficientVector & coeff ) { if ( m_UpSampleFactor == 0 ) return coeff; diff --git a/Code/MultiScale/otbWaveletPacketForwardTransform.h b/Code/MultiScale/otbWaveletPacketForwardTransform.h index e73818d8fb..0a6b38d3b3 100644 --- a/Code/MultiScale/otbWaveletPacketForwardTransform.h +++ b/Code/MultiScale/otbWaveletPacketForwardTransform.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,7 +23,8 @@ #include "otbImageToImageListFilter.h" -namespace otb { +namespace otb +{ /** \class WaveletPacketForwardTransform * \brief Wavelet packet transformation framework @@ -34,12 +35,12 @@ namespace otb { * * It yields a list of images... * - * TODO: this class implements the decomposition only. But there is no storage + * TODO: this class implements the decomposition only. But there is no storage * of the way of decomposition. It should be added before implementing backward * transformation. * - * the user is supposed to initialize Cost properly (through GetCost() macro) - * depending on its type before calling an Update(). The Cost class has to contain + * the user is supposed to initialize Cost properly (through GetCost() macro) + * depending on its type before calling an Update(). The Cost class has to contain * a New() and Evaluate() function. * * \sa FullyDecomposedWaveletPacketCost @@ -49,20 +50,20 @@ namespace otb { */ template < class TInputImage, class TOutputImage, class TFilter, class TCost > class ITK_EXPORT WaveletPacketForwardTransform - : public ImageToImageListFilter< TInputImage, TOutputImage > + : public ImageToImageListFilter< TInputImage, TOutputImage > { public: /** Standard typedefs */ typedef WaveletPacketForwardTransform Self; typedef ImageToImageListFilter< TInputImage, TOutputImage > Superclass; typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef itk::SmartPointer<const Self> ConstPointer; - /** Type macro */ - itkNewMacro(Self); + /** Type macro */ + itkNewMacro(Self); - /** Creation through object factory macro */ - itkTypeMacro(WaveletPacketForwardTransform,ImageToImageListFilter); + /** Creation through object factory macro */ + itkTypeMacro(WaveletPacketForwardTransform,ImageToImageListFilter); typedef TInputImage InputImageType; typedef typename InputImageType::Pointer InputImagePointerType; @@ -90,7 +91,7 @@ public: typedef typename CostType::Pointer CostPointerType; itkGetObjectMacro(Cost,CostType); - + itkStaticConstMacro(InputImageDimension, unsigned int,TInputImage::ImageDimension); protected: diff --git a/Code/MultiScale/otbWaveletPacketForwardTransform.txx b/Code/MultiScale/otbWaveletPacketForwardTransform.txx index 1a03bf6ee1..4f89390d10 100644 --- a/Code/MultiScale/otbWaveletPacketForwardTransform.txx +++ b/Code/MultiScale/otbWaveletPacketForwardTransform.txx @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -23,7 +23,8 @@ #include "otbWaveletPacketForwardTransform.h" -namespace otb { +namespace otb +{ template < class TInputImage, class TOutputImage, class TFilter, class TCost > WaveletPacketForwardTransform< TInputImage, TOutputImage, TFilter, TCost > @@ -55,8 +56,8 @@ WaveletPacketForwardTransform< TInputImage, TOutputImage, TFilter, TCost > * Loop decompositions */ for ( OutputImageIterator outputIt = this->GetOutput()->Begin(); - outputIt != this->GetOutput()->End(); - ++outputIt ) + outputIt != this->GetOutput()->End(); + ++outputIt ) { PerformDecomposition( 1, outputIt ); } diff --git a/Code/MultiScale/otb_9_7_Operator.h b/Code/MultiScale/otb_9_7_Operator.h index d1bb21d52c..af31c67c2e 100644 --- a/Code/MultiScale/otb_9_7_Operator.h +++ b/Code/MultiScale/otb_9_7_Operator.h @@ -9,11 +9,11 @@ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. See OTBCopyright.txt for details. - Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. + Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved. See ITCopyright.txt for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,17 +22,18 @@ #include "otbWaveletOperator.h" -namespace otb { +namespace otb +{ /** * \class LowPass_9_7_Operator * * \brief A NeighborhoodOperator for performing a 9/7 based filtering * at a pixel location. - * - * LowPass_9_7_Operator is a NeighborhoodOperator that should be applied a - * NeighborhoodIterator using the NeighborhoodInnerProduct method. - * The _9_7_ Operator is defiend in 1D as + * + * LowPass_9_7_Operator is a NeighborhoodOperator that should be applied a + * NeighborhoodIterator using the NeighborhoodInnerProduct method. + * The _9_7_ Operator is defiend in 1D as * \$ H(z) = 0.026748757411 z^{-4} -0.016864118443 z^{-3} -0.078223266529 z^{-2} * + 0.266864118443 z^{-1} + 0.602949018236 + 0.266864118443 z * -0.078223266529 z^2 -0.016864118443 z^3 + 0.026748757411 z^4 \$. @@ -44,13 +45,13 @@ namespace otb { * \sa Neighborhood * \sa ForwardDifferenceOperator * \sa BackwardDifferenceOperator - * + * * \ingroup Operators */ template<class TPixel, unsigned int VDimension, - class TAllocator = itk::NeighborhoodAllocator< TPixel > > +class TAllocator = itk::NeighborhoodAllocator< TPixel > > class ITK_EXPORT LowPass_9_7_Operator - : public WaveletOperator<TPixel, VDimension, TAllocator> + : public WaveletOperator<TPixel, VDimension, TAllocator> { public: /** Standard typedefs */ @@ -58,15 +59,15 @@ public: typedef WaveletOperator<TPixel, VDimension, TAllocator> Superclass; itkTypeMacro(LowPass_9_7_Operator, WaveletOperator); - - LowPass_9_7_Operator() - { + + LowPass_9_7_Operator() + { this->SetRadius(4); - this->CreateToRadius(4); + this->CreateToRadius(4); } LowPass_9_7_Operator(const Self& other) - : WaveletOperator<TPixel, VDimension, TAllocator>(other) + : WaveletOperator<TPixel, VDimension, TAllocator>(other) { /* ... */ } @@ -82,8 +83,8 @@ public: /** * Prints some debugging information */ - virtual void PrintSelf(std::ostream &os, itk::Indent i) const - { + virtual void PrintSelf(std::ostream &os, itk::Indent i) const + { Superclass::PrintSelf(os, i.GetNextIndent()); os << i << "LowPass_9_7_Operator {this=" << this << "}" << std::endl; } @@ -103,13 +104,13 @@ protected: { CoefficientVector coeff; coeff.push_back( 0.026748757411); - coeff.push_back(-0.016864118443); - coeff.push_back(-0.078223266529); - coeff.push_back( 0.266864118443); - coeff.push_back( 0.602949018236); - coeff.push_back( 0.266864118443); - coeff.push_back(-0.078223266529); - coeff.push_back(-0.016864118443); + coeff.push_back(-0.016864118443); + coeff.push_back(-0.078223266529); + coeff.push_back( 0.266864118443); + coeff.push_back( 0.602949018236); + coeff.push_back( 0.266864118443); + coeff.push_back(-0.078223266529); + coeff.push_back(-0.016864118443); coeff.push_back( 0.026748757411); return Superclass::UpSamplingCoefficients( coeff ); @@ -117,8 +118,8 @@ protected: /** Arranges coefficients spatially in the memory buffer. */ void Fill(const CoefficientVector& coeff) - { - this->FillCenteredDirectional(coeff); + { + this->FillCenteredDirectional(coeff); } }; @@ -127,10 +128,10 @@ protected: * * \brief A NeighborhoodOperator for performing a 9/7 based filtering * at a pixel location. - * - * HighPass_9_7_Operator is a NeighborhoodOperator that should be applied a - * NeighborhoodIterator using the NeighborhoodInnerProduct method. - * The _9_7_ Operator is defiend in 1D as + * + * HighPass_9_7_Operator is a NeighborhoodOperator that should be applied a + * NeighborhoodIterator using the NeighborhoodInnerProduct method. + * The _9_7_ Operator is defiend in 1D as * \$ H(z) = 0.045635881557 z^{-3} -0.028771763114 z^{-2} -0.295635881557 z^{-1} * + 0.557543526229 - 0.295635881557 z -0.028771763114 z^2 + 0.045635881557 z^3 \$. * @@ -141,13 +142,13 @@ protected: * \sa Neighborhood * \sa ForwardDifferenceOperator * \sa BackwardDifferenceOperator - * + * * \ingroup Operators */ template<class TPixel, unsigned int VDimension, - class TAllocator = itk::NeighborhoodAllocator< TPixel > > +class TAllocator = itk::NeighborhoodAllocator< TPixel > > class ITK_EXPORT HighPass_9_7_Operator - : public WaveletOperator<TPixel, VDimension, TAllocator> + : public WaveletOperator<TPixel, VDimension, TAllocator> { public: /** Standard typedefs */ @@ -155,15 +156,15 @@ public: typedef WaveletOperator<TPixel, VDimension, TAllocator> Superclass; itkTypeMacro(HighPass_9_7_Operator, WaveletOperator); - - HighPass_9_7_Operator() - { + + HighPass_9_7_Operator() + { this->SetRadius(3); - this->CreateToRadius(3); + this->CreateToRadius(3); } HighPass_9_7_Operator(const Self& other) - : WaveletOperator<TPixel, VDimension, TAllocator>(other) + : WaveletOperator<TPixel, VDimension, TAllocator>(other) { /* ... */ } @@ -179,8 +180,8 @@ public: /** * Prints some debugging information */ - virtual void PrintSelf(std::ostream &os, itk::Indent i) const - { + virtual void PrintSelf(std::ostream &os, itk::Indent i) const + { Superclass::PrintSelf(os, i.GetNextIndent()); os << i << "HighPass_9_7_Operator {this=" << this << "}" << std::endl; } @@ -212,8 +213,8 @@ protected: /** Arranges coefficients spatially in the memory buffer. */ void Fill(const CoefficientVector& coeff) - { - this->FillCenteredDirectional(coeff); + { + this->FillCenteredDirectional(coeff); } }; diff --git a/Code/Projections/otbGeocentricTransform.h b/Code/Projections/otbGeocentricTransform.h index 381ada6175..90fbeabfb6 100644 --- a/Code/Projections/otbGeocentricTransform.h +++ b/Code/Projections/otbGeocentricTransform.h @@ -25,57 +25,57 @@ PURPOSE. See the above copyright notices for more information. namespace otb { - template <InverseOrForwardTransformationEnum TDirectionOfMapping, - class TScalarType = double, - unsigned int NInputDimensions=3, - unsigned int NOutputDimensions=3> - class ITK_EXPORT GeocentricTransform: public itk::Transform<TScalarType, // Data type for scalars +template <InverseOrForwardTransformationEnum TDirectionOfMapping, +class TScalarType = double, +unsigned int NInputDimensions=3, +unsigned int NOutputDimensions=3> +class ITK_EXPORT GeocentricTransform: public itk::Transform<TScalarType, // Data type for scalars NInputDimensions, // Number of dimensions in the input space NOutputDimensions> // Number of dimensions in the output space - { - public : - /** Standard class typedefs. */ - typedef itk::Transform< TScalarType, - NInputDimensions, - NOutputDimensions > Superclass; - typedef GeocentricTransform Self; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; +{ +public : + /** Standard class typedefs. */ + typedef itk::Transform< TScalarType, + NInputDimensions, + NOutputDimensions > Superclass; + typedef GeocentricTransform Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; - typedef typename Superclass::ScalarType ScalarType; - typedef ossimProjection OssimMapProjectionType; - typedef itk::Point<ScalarType,NInputDimensions > InputPointType; - typedef itk::Point<ScalarType,NOutputDimensions > OutputPointType; + typedef typename Superclass::ScalarType ScalarType; + typedef ossimProjection OssimMapProjectionType; + typedef itk::Point<ScalarType,NInputDimensions > InputPointType; + typedef itk::Point<ScalarType,NOutputDimensions > OutputPointType; - /** Method for creation through the object factory. */ - itkNewMacro( Self ); + /** Method for creation through the object factory. */ + itkNewMacro( Self ); - /** Run-time type information (and related methods). */ - itkTypeMacro( GeocentricTransform, itk::Transform ); + /** Run-time type information (and related methods). */ + itkTypeMacro( GeocentricTransform, itk::Transform ); - typedef InverseOrForwardTransformationEnum DirectionOfMappingEnumType; + typedef InverseOrForwardTransformationEnum DirectionOfMappingEnumType; - itkStaticConstMacro(DirectionOfMapping,DirectionOfMappingEnumType,TDirectionOfMapping); - itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions); - itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions); - itkStaticConstMacro(SpaceDimension, unsigned int, NInputDimensions); - itkStaticConstMacro(ParametersDimension, unsigned int,NInputDimensions*(NInputDimensions+1)); + itkStaticConstMacro(DirectionOfMapping,DirectionOfMappingEnumType,TDirectionOfMapping); + itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions); + itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions); + itkStaticConstMacro(SpaceDimension, unsigned int, NInputDimensions); + itkStaticConstMacro(ParametersDimension, unsigned int,NInputDimensions*(NInputDimensions+1)); - OutputPointType TransformPoint(const InputPointType &point) const; + OutputPointType TransformPoint(const InputPointType &point) const; - protected: - GeocentricTransform(); - virtual ~GeocentricTransform(); - ossimEllipsoid* m_Ellipsoid; +protected: + GeocentricTransform(); + virtual ~GeocentricTransform(); + ossimEllipsoid* m_Ellipsoid; - private : - GeocentricTransform(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented +private : + GeocentricTransform(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented - }; +}; } // namespace otb diff --git a/Code/Projections/otbGeocentricTransform.txx b/Code/Projections/otbGeocentricTransform.txx index 4def38abe5..8a1336b77a 100644 --- a/Code/Projections/otbGeocentricTransform.txx +++ b/Code/Projections/otbGeocentricTransform.txx @@ -23,52 +23,52 @@ PURPOSE. See the above copyright notices for more information. namespace otb { - template<InverseOrForwardTransformationEnum TransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> - GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions> - ::GeocentricTransform() : Superclass(SpaceDimension,ParametersDimension) +template<InverseOrForwardTransformationEnum TransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> +GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions> +::GeocentricTransform() : Superclass(SpaceDimension,ParametersDimension) +{ + m_Ellipsoid = new ossimEllipsoid(); +} + +template<InverseOrForwardTransformationEnum TransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> +GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions> +::~GeocentricTransform() +{ + if (m_Ellipsoid != NULL) { - m_Ellipsoid = new ossimEllipsoid(); + delete m_Ellipsoid; } +} + +template<InverseOrForwardTransformationEnum TransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> +typename GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions>::OutputPointType +GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions> +::TransformPoint(const InputPointType & point) const +{ + OutputPointType outputPoint; - template<InverseOrForwardTransformationEnum TransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> - GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions> - ::~GeocentricTransform() + switch (DirectionOfMapping) { - if (m_Ellipsoid != NULL) - { - delete m_Ellipsoid; - } + case INVERSE: + { + m_Ellipsoid->XYZToLatLonHeight(point[0], point[1], point[2], outputPoint[1],outputPoint[0],outputPoint[2]); + break; } + case FORWARD: + { + m_Ellipsoid->latLonHeightToXYZ(point[1], point[0], point[2], outputPoint[0],outputPoint[1],outputPoint[2]); - template<InverseOrForwardTransformationEnum TransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> - typename GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions>::OutputPointType - GeocentricTransform<TransformDirection, TScalarType, NInputDimensions, NOutputDimensions> - ::TransformPoint(const InputPointType & point) const + break; + } + default: { - OutputPointType outputPoint; - - switch (DirectionOfMapping) - { - case INVERSE: - { - m_Ellipsoid->XYZToLatLonHeight(point[0], point[1], point[2], outputPoint[1],outputPoint[0],outputPoint[2]); - break; - } - case FORWARD: - { - m_Ellipsoid->latLonHeightToXYZ(point[1], point[0], point[2], outputPoint[0],outputPoint[1],outputPoint[2]); - - break; - } - default: - { - itkExceptionMacro(<<"Model is INVERSE or FORWARD only !!"); - break; - } - } - //To be completed - return outputPoint; + itkExceptionMacro(<<"Model is INVERSE or FORWARD only !!"); + break; + } } + //To be completed + return outputPoint; +} } // namespace otb diff --git a/Code/Radiometry/otbBuiltUpIndicesFunctor.h b/Code/Radiometry/otbBuiltUpIndicesFunctor.h index b5036042e5..f11f0f3c77 100644 --- a/Code/Radiometry/otbBuiltUpIndicesFunctor.h +++ b/Code/Radiometry/otbBuiltUpIndicesFunctor.h @@ -119,9 +119,9 @@ protected: double dTM4 = static_cast<double>(pTM4); double dTM5 = static_cast<double>(pTM5); if ( dTM5+dTM4 == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>((dTM5-dTM4)/(dTM5+dTM4)) ); } @@ -169,9 +169,9 @@ protected: double dRed = static_cast<double>(pRed); double dNIR = static_cast<double>(pNIR); if ( dNIR == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>(m_A - (m_B*dRed)/(dNIR)) ); } diff --git a/Code/Radiometry/otbMultiChannelGAndRIndexImageFilter.h b/Code/Radiometry/otbMultiChannelGAndRIndexImageFilter.h index adc1734278..5944b4e7c0 100644 --- a/Code/Radiometry/otbMultiChannelGAndRIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelGAndRIndexImageFilter.h @@ -36,11 +36,11 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::IR< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::IR< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelGAndRIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, TFunction> { public: /** Standard class typedefs. */ @@ -74,11 +74,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_GreenIndex < 1 || m_RedIndex < 1 || - m_GreenIndex > lNbChan || m_RedIndex > lNbChan ) - { + if (m_GreenIndex < 1 || m_RedIndex < 1 || + m_GreenIndex > lNbChan || m_RedIndex > lNbChan ) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetGreenIndex(m_GreenIndex); this->GetFunctor().SetRedIndex(m_RedIndex); } diff --git a/Code/Radiometry/otbMultiChannelRAndBAndNIRIndexImageFilter.h b/Code/Radiometry/otbMultiChannelRAndBAndNIRIndexImageFilter.h index 800809ebe4..beca7fde24 100644 --- a/Code/Radiometry/otbMultiChannelRAndBAndNIRIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelRAndBAndNIRIndexImageFilter.h @@ -36,12 +36,12 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::ARVI< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::ARVI< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelRAndBAndNIRIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> { public: /** Standard class typedefs. */ @@ -78,11 +78,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_RedIndex < 1 || m_BlueIndex < 1 || m_NIRIndex < 1 || - m_RedIndex > lNbChan || m_BlueIndex > lNbChan || m_NIRIndex > lNbChan) - { + if (m_RedIndex < 1 || m_BlueIndex < 1 || m_NIRIndex < 1 || + m_RedIndex > lNbChan || m_BlueIndex > lNbChan || m_NIRIndex > lNbChan) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetRedIndex(m_RedIndex); this->GetFunctor().SetBlueIndex(m_BlueIndex); this->GetFunctor().SetNIRIndex(m_NIRIndex); diff --git a/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.h b/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.h index 63e9659a92..5cf31899b5 100644 --- a/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelRAndBAndNIRVegetationIndexImageFilter.h @@ -36,12 +36,12 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::ARVI< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::ARVI< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelRAndBAndNIRVegetationIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> { public: /** Standard class typedefs. */ @@ -78,11 +78,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_RedIndex < 1 || m_BlueIndex < 1 || m_NIRIndex < 1 || - m_RedIndex > lNbChan || m_BlueIndex > lNbChan || m_NIRIndex > lNbChan) - { + if (m_RedIndex < 1 || m_BlueIndex < 1 || m_NIRIndex < 1 || + m_RedIndex > lNbChan || m_BlueIndex > lNbChan || m_NIRIndex > lNbChan) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetRedIndex(m_RedIndex); this->GetFunctor().SetBlueIndex(m_BlueIndex); this->GetFunctor().SetNIRIndex(m_NIRIndex); diff --git a/Code/Radiometry/otbMultiChannelRAndGAndNIRIndexImageFilter.h b/Code/Radiometry/otbMultiChannelRAndGAndNIRIndexImageFilter.h index 6569e5f1df..738943575b 100644 --- a/Code/Radiometry/otbMultiChannelRAndGAndNIRIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelRAndGAndNIRIndexImageFilter.h @@ -36,12 +36,12 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::AVI< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::AVI< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelRAndGAndNIRIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> { public: /** Standard class typedefs. */ @@ -78,11 +78,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_RedIndex < 1 || m_GreenIndex < 1 || m_NIRIndex < 1 || - m_RedIndex > lNbChan || m_GreenIndex > lNbChan || m_NIRIndex > lNbChan) - { + if (m_RedIndex < 1 || m_GreenIndex < 1 || m_NIRIndex < 1 || + m_RedIndex > lNbChan || m_GreenIndex > lNbChan || m_NIRIndex > lNbChan) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetRedIndex(m_RedIndex); this->GetFunctor().SetGreenIndex(m_GreenIndex); this->GetFunctor().SetNIRIndex(m_NIRIndex); diff --git a/Code/Radiometry/otbMultiChannelRAndGAndNIRVegetationIndexImageFilter.h b/Code/Radiometry/otbMultiChannelRAndGAndNIRVegetationIndexImageFilter.h index c2a2e49961..3fd0ea4696 100644 --- a/Code/Radiometry/otbMultiChannelRAndGAndNIRVegetationIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelRAndGAndNIRVegetationIndexImageFilter.h @@ -36,12 +36,12 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::AVI< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::AVI< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelRAndGAndNIRVegetationIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction> { public: /** Standard class typedefs. */ @@ -78,11 +78,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_RedIndex < 1 || m_GreenIndex < 1 || m_NIRIndex < 1 || - m_RedIndex > lNbChan || m_GreenIndex > lNbChan || m_NIRIndex > lNbChan) - { + if (m_RedIndex < 1 || m_GreenIndex < 1 || m_NIRIndex < 1 || + m_RedIndex > lNbChan || m_GreenIndex > lNbChan || m_NIRIndex > lNbChan) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetRedIndex(m_RedIndex); this->GetFunctor().SetGreenIndex(m_GreenIndex); this->GetFunctor().SetNIRIndex(m_NIRIndex); diff --git a/Code/Radiometry/otbMultiChannelRAndNIRIndexImageFilter.h b/Code/Radiometry/otbMultiChannelRAndNIRIndexImageFilter.h index e681331466..40259d9214 100644 --- a/Code/Radiometry/otbMultiChannelRAndNIRIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelRAndNIRIndexImageFilter.h @@ -36,11 +36,11 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::NDVI< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::NDVI< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelRAndNIRIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, TFunction> { public: /** Standard class typedefs. */ @@ -74,11 +74,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_RedIndex < 1 || m_NIRIndex < 1 || - m_RedIndex > lNbChan || m_NIRIndex > lNbChan) - { + if (m_RedIndex < 1 || m_NIRIndex < 1 || + m_RedIndex > lNbChan || m_NIRIndex > lNbChan) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetRedIndex(m_RedIndex); this->GetFunctor().SetNIRIndex(m_NIRIndex); } diff --git a/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.h b/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.h index 07c7a76dd9..cd9fe15d35 100644 --- a/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.h +++ b/Code/Radiometry/otbMultiChannelRAndNIRVegetationIndexImageFilter.h @@ -37,11 +37,11 @@ namespace otb * \ingroup Radiometry */ template <class TInputImage, class TOutputImage, - class TFunction = Functor::NDVI< typename TInputImage::InternalPixelType, - typename TInputImage::InternalPixelType, - typename TOutputImage::PixelType> > +class TFunction = Functor::NDVI< typename TInputImage::InternalPixelType, +typename TInputImage::InternalPixelType, +typename TOutputImage::PixelType> > class ITK_EXPORT MultiChannelRAndNIRVegetationIndexImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, TFunction> + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, TFunction> { public: /** Standard class typedefs. */ @@ -75,11 +75,11 @@ protected: virtual void BeforeThreadedGenerateData() { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); - if(m_RedIndex < 1 || m_NIRIndex < 1 || - m_RedIndex > lNbChan || m_NIRIndex > lNbChan) - { + if (m_RedIndex < 1 || m_NIRIndex < 1 || + m_RedIndex > lNbChan || m_NIRIndex > lNbChan) + { itkExceptionMacro(<<"Channel indices must belong to range [1, ...["); - } + } this->GetFunctor().SetRedIndex(m_RedIndex); this->GetFunctor().SetNIRIndex(m_NIRIndex); } diff --git a/Code/Radiometry/otbSoilIndicesFunctor.h b/Code/Radiometry/otbSoilIndicesFunctor.h index 1628e4ac52..4c264b9e88 100644 --- a/Code/Radiometry/otbSoilIndicesFunctor.h +++ b/Code/Radiometry/otbSoilIndicesFunctor.h @@ -193,9 +193,9 @@ protected: double dGreen = static_cast<double>(pGreen); double dRed = static_cast<double>(pRed); if ( dGreen == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( vcl_pow(dRed,2.)/vcl_pow(dGreen,3.) ) ); } @@ -224,9 +224,9 @@ protected: double dGreen = static_cast<double>(pGreen); double dRed = static_cast<double>(pRed); if ( dGreen + dRed == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( (dRed - dGreen)/(dRed + dGreen) ) ); } diff --git a/Code/Radiometry/otbVegetationIndicesFunctor.h b/Code/Radiometry/otbVegetationIndicesFunctor.h index 339ffaab8d..fbfbc60218 100644 --- a/Code/Radiometry/otbVegetationIndicesFunctor.h +++ b/Code/Radiometry/otbVegetationIndicesFunctor.h @@ -266,9 +266,9 @@ protected: double dr = static_cast<double>(r); double dnir = static_cast<double>(nir); if ( (nir + r) == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>((dnir-dr)/(dnir+dr))); } @@ -294,9 +294,9 @@ protected: double dr = static_cast<double>(r); double dnir = static_cast<double>(nir); if ( r == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>(dnir/dr)); } }; @@ -383,9 +383,9 @@ protected: double dr = static_cast<double>(r); double denominator = dnir + dr + m_L; if ( denominator == 0. ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( ((dnir-dr)*(1+m_L))/denominator ) ); } @@ -445,9 +445,9 @@ protected: double dr = static_cast<double>(r); double denominator = m_A*dnir + dr + m_X*(1.+m_A*m_A); if ( denominator == 0. ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( (m_A*(dnir - m_A*dr - m_S))/denominator ) ); } @@ -483,9 +483,9 @@ protected: double dr = static_cast<double>(r); double sqrt_value = (2*dnir+1)*(2*dnir+1) - 8*(dnir-dr); if ( sqrt_value < 0. ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( (2*dnir + 1 - vcl_sqrt(sqrt_value))/2. ) ); } @@ -516,14 +516,14 @@ protected: double dnumerateur_nu; double ddenominateur_nu = dnir + dr + 0.5; if ( ddenominateur_nu == 0 ) - { - dnu = 0; - } + { + dnu = 0; + } else - { - dnumerateur_nu = 2*(dnir*dnir - dr*dr) + 1.5*dnir + 0.5*dr; - dnu = dnumerateur_nu / ddenominateur_nu; - } + { + dnumerateur_nu = 2*(dnir*dnir - dr*dr) + 1.5*dnir + 0.5*dr; + dnu = dnumerateur_nu / ddenominateur_nu; + } double ddenominateur_GEMI = 1 - dr; if ( ddenominateur_GEMI == 0. ) @@ -552,7 +552,7 @@ public: /// Desctructor ~WDVI() {}; // Operator on r and nir single pixel values -/** Set/Get Slop of soil line */ + /** Set/Get Slop of soil line */ void SetS(const double s) { m_S = s; @@ -590,7 +590,7 @@ public: typedef WDVI<TInput1, TInput2, TOutput> WDVIFunctorType; MSAVI() : m_S(0.4) {}; ~MSAVI() {}; -/** Set/Get Slop of soil line */ + /** Set/Get Slop of soil line */ void SetS(const double s) { m_S = s; @@ -621,9 +621,9 @@ protected: double denominator = dnir + dr + dL; if ( denominator == 0. ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( ((dnir-dr)*(1+dL))/denominator ) ); } @@ -651,7 +651,7 @@ class AVI : public RAndGAndNIRIndexBase<TInput1,TInput2,TInput3,TOutput> public: AVI() : m_LambdaG(560.), m_LambdaR(660.), m_LambdaNir(830.) {}; ~AVI() {}; -/** Set/Get Lambda red parameter*/ + /** Set/Get Lambda red parameter*/ void SetLambdaR(const double lr) { m_LambdaR = lr; @@ -660,7 +660,7 @@ public: { return (m_LambdaR); } -/** Set/Get Lambda green parameter */ + /** Set/Get Lambda green parameter */ void SetLambdaG(const double lg) { m_LambdaG = lg; @@ -669,7 +669,7 @@ public: { return (m_LambdaG); } -/** Set/Get Lambda red parameter */ + /** Set/Get Lambda red parameter */ void SetLambdaNir(const double lnir) { m_LambdaNir = lnir; @@ -689,7 +689,7 @@ protected: double dfact2 = (m_LambdaR - m_LambdaG) / m_LambdaR; double dterm1; double dterm2; - if( (dnir-dr) == 0 ) + if ( (dnir-dr) == 0 ) { dterm1 = 0; } @@ -698,7 +698,7 @@ protected: dterm1 = vcl_atan(dfact1/(dnir - dr)); } - if( (dg-dr) == 0 ) + if ( (dg-dr) == 0 ) { dterm2 = 0; } @@ -758,9 +758,9 @@ protected: double RHOrb = dr - m_Gamma*(db - dr); double denominator = dnir + RHOrb; if ( denominator == 0. ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>( (dnir - RHOrb)/denominator ) ); } @@ -864,7 +864,7 @@ class EVI : public RAndBAndNIRIndexBase<TInput1,TInput2,TInput3,TOutput> public: EVI() : m_G(2.5), m_C1(6.0), m_C2(7.5), m_L(1.0) {}; ~EVI() {}; -/** Set/Get G parameter */ + /** Set/Get G parameter */ void SetG(const double g) { m_G = g; @@ -908,9 +908,9 @@ protected: double dnir = static_cast<double>(nir); double denominator = dnir + m_C1*dr - m_C2*db + m_L; if ( denominator == 0. ) - { + { return ( static_cast<TOutput>(0.) ); - } + } return ( static_cast<TOutput>( m_G * (dnir - dr)/denominator ) ); } @@ -985,7 +985,7 @@ protected: inline TOutput Evaluate(const TInput1 &r, const TInput2 &nir) const { double dval = this->GetNDVI()(r,nir) + 0.5; - if(dval<0) + if (dval<0) return ( static_cast<TOutput>(0)); return ( static_cast<TOutput>(vcl_sqrt(dval))); } diff --git a/Code/Radiometry/otbWaterIndicesFunctor.h b/Code/Radiometry/otbWaterIndicesFunctor.h index b3e9431c3c..1d2bb35934 100644 --- a/Code/Radiometry/otbWaterIndicesFunctor.h +++ b/Code/Radiometry/otbWaterIndicesFunctor.h @@ -111,9 +111,9 @@ protected: double dindex2 = static_cast<double>(id2); double ddenom = dindex1 + dindex2; if ( ddenom == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>((dindex1- dindex2)/ddenom)); } }; @@ -145,9 +145,9 @@ protected: double drho860 = static_cast<double>(rho860); double drho1240 = static_cast<double>(rho1240); if ( drho1240 == 0 ) - { + { return static_cast<TOutput>(0.); - } + } return ( static_cast<TOutput>(drho860/drho1240) ); } }; @@ -346,7 +346,7 @@ public: { return this->GetIndex1; } - /// Set Index G +/// Set Index G void SetGIndex(unsigned int channel) { this->SetIndex2(channel); @@ -399,7 +399,7 @@ public: { return this->GetIndex1; } - /// Set Index G +/// Set Index G void SetGIndex(unsigned int channel) { this->SetIndex2(channel); diff --git a/Code/SpatialReasoning/otbPolygonListToRCC8GraphFilter.txx b/Code/SpatialReasoning/otbPolygonListToRCC8GraphFilter.txx index 45d96e97be..02ff04c1df 100644 --- a/Code/SpatialReasoning/otbPolygonListToRCC8GraphFilter.txx +++ b/Code/SpatialReasoning/otbPolygonListToRCC8GraphFilter.txx @@ -341,18 +341,18 @@ PolygonListToRCC8GraphFilter<TPolygonList, TOutputGraph> { // Add the edge to the graph. otbMsgDevMacro(<<"Adding edge: "<<vIt1.GetIndex()<<" -> "<<vIt2.GetIndex()<<": "<<value); - if(value==OTB_RCC8_NTPPI) - { - m_EdgesPerThread[threadId][EdgePairType(vIt2.GetIndex(),vIt1.GetIndex())]=OTB_RCC8_NTPP; - } - else if(value == OTB_RCC8_TPPI) - { - m_EdgesPerThread[threadId][EdgePairType(vIt2.GetIndex(),vIt1.GetIndex())]=OTB_RCC8_TPP; - } - else - { - m_EdgesPerThread[threadId][EdgePairType(vIt1.GetIndex(),vIt2.GetIndex())]=value; - } + if (value==OTB_RCC8_NTPPI) + { + m_EdgesPerThread[threadId][EdgePairType(vIt2.GetIndex(),vIt1.GetIndex())]=OTB_RCC8_NTPP; + } + else if (value == OTB_RCC8_TPPI) + { + m_EdgesPerThread[threadId][EdgePairType(vIt2.GetIndex(),vIt1.GetIndex())]=OTB_RCC8_TPP; + } + else + { + m_EdgesPerThread[threadId][EdgePairType(vIt1.GetIndex(),vIt2.GetIndex())]=value; + } if (m_UseInverted) { m_EdgesPerThread[threadId][EdgePairType(vIt2.GetIndex(),vIt1.GetIndex())]=invert[value]; diff --git a/Code/Visu/otbImageViewerBase.txx b/Code/Visu/otbImageViewerBase.txx index 967afb7c66..4620de9ae9 100644 --- a/Code/Visu/otbImageViewerBase.txx +++ b/Code/Visu/otbImageViewerBase.txx @@ -1045,19 +1045,19 @@ void ImageViewerBase<TPixel,TLabel> ::SetViewModel(ViewModelType viewModel) { - // Channel indices outofbound check - if(m_RedChannelIndex >= m_InputImage->GetNumberOfComponentsPerPixel()) - { - itkExceptionMacro(<<"Red channel index out of bound."); - } - if(viewModel != ScrollWidgetType::GRAYSCALE && m_GreenChannelIndex >= m_InputImage->GetNumberOfComponentsPerPixel()) - { + // Channel indices outofbound check + if (m_RedChannelIndex >= m_InputImage->GetNumberOfComponentsPerPixel()) + { + itkExceptionMacro(<<"Red channel index out of bound."); + } + if (viewModel != ScrollWidgetType::GRAYSCALE && m_GreenChannelIndex >= m_InputImage->GetNumberOfComponentsPerPixel()) + { itkExceptionMacro(<<"Green channel index out of bound."); - } - if(viewModel == ScrollWidgetType::RGB && m_BlueChannelIndex >= m_InputImage->GetNumberOfComponentsPerPixel()) - { + } + if (viewModel == ScrollWidgetType::RGB && m_BlueChannelIndex >= m_InputImage->GetNumberOfComponentsPerPixel()) + { itkExceptionMacro(<<"Blue channel index out of bound."); - } + } switch (viewModel) { diff --git a/Code/Visu/otbImageWidgetBase.txx b/Code/Visu/otbImageWidgetBase.txx index e3057b33f6..e35bec7582 100644 --- a/Code/Visu/otbImageWidgetBase.txx +++ b/Code/Visu/otbImageWidgetBase.txx @@ -442,18 +442,18 @@ ImageWidgetBase<TPixel> ::RebuildOpenGlBuffer(void) { // Channel indices outofbound check - if(m_RedChannelIndex >= m_Image->GetNumberOfComponentsPerPixel()) - { - itkExceptionMacro(<<"Red channel index out of bound."); - } - if(m_ViewModel != GRAYSCALE && m_GreenChannelIndex >= m_Image->GetNumberOfComponentsPerPixel()) - { + if (m_RedChannelIndex >= m_Image->GetNumberOfComponentsPerPixel()) + { + itkExceptionMacro(<<"Red channel index out of bound."); + } + if (m_ViewModel != GRAYSCALE && m_GreenChannelIndex >= m_Image->GetNumberOfComponentsPerPixel()) + { itkExceptionMacro(<<"Green channel index out of bound."); - } - if(m_ViewModel == RGB && m_BlueChannelIndex >= m_Image->GetNumberOfComponentsPerPixel()) - { + } + if (m_ViewModel == RGB && m_BlueChannelIndex >= m_Image->GetNumberOfComponentsPerPixel()) + { itkExceptionMacro(<<"Blue channel index out of bound."); - } + } diff --git a/Code/VisuRefac/otbBlendingFunction.h b/Code/VisuRefac/otbBlendingFunction.h index 39d75459b8..233e4ea797 100644 --- a/Code/VisuRefac/otbBlendingFunction.h +++ b/Code/VisuRefac/otbBlendingFunction.h @@ -32,7 +32,7 @@ namespace Function */ template <class TInputRGBPixel1, class TInputRGBPixel2 = TInputRGBPixel1, class TOutputRGBPixel = TInputRGBPixel1> class BlendingFunction - : public itk::Object + : public itk::Object { public: /** Standard class typedefs */ @@ -51,7 +51,7 @@ public: /** Evaluate method */ virtual const OutputRGBPixelType Evaluate(const InputPixel1Type& input1, const InputPixel2Type & input2) = 0; - + protected: /** Constructor */ BlendingFunction() {} diff --git a/Code/VisuRefac/otbBlendingImageFilter.h b/Code/VisuRefac/otbBlendingImageFilter.h index d1a458ae7f..191b27d023 100644 --- a/Code/VisuRefac/otbBlendingImageFilter.h +++ b/Code/VisuRefac/otbBlendingImageFilter.h @@ -40,12 +40,12 @@ class BlendingFunctor public: /** Blending function typedef */ typedef otb::Function::BlendingFunction<TInputPixel1, - TInputPixel2,TOutputPixel> BlendingFunctionType; + TInputPixel2,TOutputPixel> BlendingFunctionType; /** Blending function pointer typedef */ typedef typename BlendingFunctionType::Pointer BlendingFunctionPointerType; /** Default rendering function typedef */ typedef otb::Function::UniformAlphaBlendingFunction<TInputPixel1, - TInputPixel2,TOutputPixel> DefaultBlendingFunctionType; + TInputPixel2,TOutputPixel> DefaultBlendingFunctionType; /** Scalar pixel operator */ inline TOutputPixel operator()(const TInputPixel1 & input1, const TInputPixel2 & input2) @@ -53,7 +53,7 @@ public: return m_Function->Evaluate(input1,input2); } -/** Constructor */ + /** Constructor */ BlendingFunctor() { // Default rendering function @@ -61,7 +61,7 @@ public: } /** Destructor */ - ~BlendingFunctor(){} + ~BlendingFunctor() {} /** Set the rendering function * \param function the Blending function. @@ -96,20 +96,20 @@ private: */ template <class TInputImage1, class TInputImage2 = TInputImage1, class TOutputImage = TInputImage1> class BlendingImageFilter - : public itk::BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, - Functor::BlendingFunctor - < typename TInputImage1::PixelType, - typename TInputImage2::PixelType, - typename TOutputImage::PixelType > > + : public itk::BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, + Functor::BlendingFunctor + < typename TInputImage1::PixelType, + typename TInputImage2::PixelType, + typename TOutputImage::PixelType > > { public: /** Standard typedefs */ typedef BlendingImageFilter Self; typedef itk::BinaryFunctorImageFilter <TInputImage1,TInputImage2,TOutputImage, Functor::BlendingFunctor - < typename TInputImage1::PixelType, - typename TInputImage2::PixelType, - typename TOutputImage::PixelType > > Superclass; + < typename TInputImage1::PixelType, + typename TInputImage2::PixelType, + typename TOutputImage::PixelType > > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -122,8 +122,8 @@ public: /** Blending function typedef */ typedef Functor::BlendingFunctor < typename TInputImage1::PixelType, - typename TInputImage2::PixelType, - typename TOutputImage::PixelType > BlendingFunctorType; + typename TInputImage2::PixelType, + typename TOutputImage::PixelType > BlendingFunctorType; typedef typename BlendingFunctorType::BlendingFunctionType BlendingFunctionType; /** @@ -145,7 +145,7 @@ public: return this->GetFunctor().GetFunction(); } - protected: +protected: /** Constructor */ BlendingImageFilter() {} /** Destructor */ diff --git a/Code/VisuRefac/otbChangeExtractRegionActionHandler.h b/Code/VisuRefac/otbChangeExtractRegionActionHandler.h index 35958b20df..6b53bdba17 100644 --- a/Code/VisuRefac/otbChangeExtractRegionActionHandler.h +++ b/Code/VisuRefac/otbChangeExtractRegionActionHandler.h @@ -24,14 +24,14 @@ namespace otb { /** \class ChangeExtractRegionActionHandler * \brief Implements basic Scroll, Full and Zoom widgets resizing. -* +* * \sa ImageWidgetController * \sa ImageWidgetActionHandler */ -template <class TModel, class TView> +template <class TModel, class TView> class ChangeExtractRegionActionHandler - : public ImageWidgetActionHandler + : public ImageWidgetActionHandler { public: /** Standard class typedefs */ @@ -39,10 +39,10 @@ public: typedef ImageWidgetActionHandler Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(ChangeExtractRegionActionHandler,ImageWidgetActionHandler); @@ -63,25 +63,25 @@ public: */ virtual bool HandleWidgetEvent(std::string widgetId, int event) { - if( m_View.IsNotNull() && m_Model.IsNotNull() ) + if ( m_View.IsNotNull() && m_Model.IsNotNull() ) + { + if (widgetId == m_View->GetScrollWidget()->GetIdentifier() + && event == FL_PUSH) { - if(widgetId == m_View->GetScrollWidget()->GetIdentifier() - && event == FL_PUSH) - { - // Get the clicked index - typename ViewType::IndexType index; - index[0] = Fl::event_x(); - index[1] = Fl::event_y(); - // Change scaled extract region center - m_Model->SetExtractRegionSubsampledCenter(m_View->GetScrollWidget()->ScreenIndexToRegionIndex(index)); - // Update model - m_Model->Update(); - return true; - } + // Get the clicked index + typename ViewType::IndexType index; + index[0] = Fl::event_x(); + index[1] = Fl::event_y(); + // Change scaled extract region center + m_Model->SetExtractRegionSubsampledCenter(m_View->GetScrollWidget()->ScreenIndexToRegionIndex(index)); + // Update model + m_Model->Update(); + return true; } + } return false; } - + /** Set/Get the pointer to the view */ itkSetObjectMacro(View,ViewType); itkGetObjectMacro(View,ViewType); @@ -96,24 +96,24 @@ protected: {} /** Destructor */ - virtual ~ChangeExtractRegionActionHandler(){} + virtual ~ChangeExtractRegionActionHandler() {} /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os,indent); } - + private: ChangeExtractRegionActionHandler(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented // Pointer to the view ViewPointerType m_View; - + // Pointer to the model ModelPointerType m_Model; - -}; // end class + +}; // end class } // end namespace otb #endif diff --git a/Code/VisuRefac/otbChangeScaledExtractRegionActionHandler.h b/Code/VisuRefac/otbChangeScaledExtractRegionActionHandler.h index 49eb9db962..eed312c647 100644 --- a/Code/VisuRefac/otbChangeScaledExtractRegionActionHandler.h +++ b/Code/VisuRefac/otbChangeScaledExtractRegionActionHandler.h @@ -24,14 +24,14 @@ namespace otb { /** \class ChangeScaledExtractRegionActionHandler * \brief Implements basic Scroll, Full and Zoom widgets resizing. -* +* * \sa ImageWidgetController * \sa ImageWidgetActionHandler */ -template <class TModel, class TView> +template <class TModel, class TView> class ChangeScaledExtractRegionActionHandler - : public ImageWidgetActionHandler + : public ImageWidgetActionHandler { public: /** Standard class typedefs */ @@ -39,10 +39,10 @@ public: typedef ImageWidgetActionHandler Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(ChangeScaledExtractRegionActionHandler,ImageWidgetActionHandler); @@ -63,25 +63,25 @@ public: */ virtual bool HandleWidgetEvent(std::string widgetId, int event) { - if( m_View.IsNotNull() && m_Model.IsNotNull() ) + if ( m_View.IsNotNull() && m_Model.IsNotNull() ) + { + if (widgetId == m_View->GetFullWidget()->GetIdentifier() + && event == FL_PUSH) { - if(widgetId == m_View->GetFullWidget()->GetIdentifier() - && event == FL_PUSH) - { - // Get the clicked index - typename ViewType::IndexType index; - index[0] = Fl::event_x(); - index[1] = Fl::event_y(); - // Change scaled extract region center - m_Model->SetScaledExtractRegionCenter(m_View->GetFullWidget()->ScreenIndexToRegionIndex(index)); - // Update model - m_Model->Update(); - return true; - } + // Get the clicked index + typename ViewType::IndexType index; + index[0] = Fl::event_x(); + index[1] = Fl::event_y(); + // Change scaled extract region center + m_Model->SetScaledExtractRegionCenter(m_View->GetFullWidget()->ScreenIndexToRegionIndex(index)); + // Update model + m_Model->Update(); + return true; } + } return false; } - + /** Set/Get the pointer to the view */ itkSetObjectMacro(View,ViewType); itkGetObjectMacro(View,ViewType); @@ -96,24 +96,24 @@ protected: {} /** Destructor */ - virtual ~ChangeScaledExtractRegionActionHandler(){} + virtual ~ChangeScaledExtractRegionActionHandler() {} /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os,indent); } - + private: ChangeScaledExtractRegionActionHandler(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented // Pointer to the view ViewPointerType m_View; - + // Pointer to the model ModelPointerType m_Model; - -}; // end class + +}; // end class } // end namespace otb #endif diff --git a/Code/VisuRefac/otbImageLayer.h b/Code/VisuRefac/otbImageLayer.h index 8f442ea24d..1c4219a60d 100644 --- a/Code/VisuRefac/otbImageLayer.h +++ b/Code/VisuRefac/otbImageLayer.h @@ -32,14 +32,14 @@ namespace otb /** \class ImageLayer * \brief This class is a layer container. * It contains everything related to a layer in the viewer model. -* +* * \sa ImageViewerModel * \sa Layer */ -template <class TImage, class TOutputImage = otb::Image<itk::RGBPixel<unsigned char>, 2 > > +template <class TImage, class TOutputImage = otb::Image<itk::RGBPixel<unsigned char>, 2 > > class ImageLayer - : public Layer<TOutputImage> + : public Layer<TOutputImage> { public: /** Standard class typedefs */ @@ -47,10 +47,10 @@ public: typedef Layer<TOutputImage> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(ImageLayer,Layer); @@ -60,53 +60,53 @@ public: typedef typename ImageType::PixelType PixelType; typedef typename ImageType::InternalPixelType InternalPixelType; typedef typename ImageType::RegionType RegionType; - + /** Output image typedef */ typedef TOutputImage OutputImageType; /** Histogram typedef */ - typedef itk::Statistics::DenseFrequencyContainer DFContainerType; - + typedef itk::Statistics::DenseFrequencyContainer DFContainerType; + typedef itk::VariableLengthVector<InternalPixelType> SampleType; typedef itk::Statistics::ListSample<SampleType> ListSampleType; - + typedef otb::ListSampleToVariableDimensionHistogramGenerator <ListSampleType,InternalPixelType,DFContainerType> HistogramFilterType; typedef typename HistogramFilterType::HistogramType HistogramType; typedef typename HistogramType::Pointer HistogramPointerType; - + /** Rendering part */ typedef RenderingImageFilter<TImage,TOutputImage> RenderingFilterType; typedef typename RenderingFilterType::Pointer RenderingFilterPointerType; typedef typename RenderingFilterType::RenderingFunctionType RenderingFunctionType; typedef typename RenderingFunctionType::Pointer RenderingFunctionPointerType; typedef Function::StandardRenderingFunction<InternalPixelType, - typename TOutputImage::PixelType> DefaultRenderingFunctionType; + typename TOutputImage::PixelType> DefaultRenderingFunctionType; typedef itk::ExtractImageFilter<ImageType,ImageType> ExtractFilterType; typedef typename ExtractFilterType::Pointer ExtractFilterPointerType; /** Set/Get the image */ void SetImage(ImageType * img) { - if(m_Image != img) - { + if (m_Image != img) + { m_Image = img; m_ExtractFilter->SetInput(m_Image); m_ScaledExtractFilter->SetInput(m_Image); - } + } } itkGetObjectMacro(Image,ImageType); /** Set/Get the quicklook */ void SetQuicklook(ImageType * ql) { - if(m_Quicklook != ql) - { + if (m_Quicklook != ql) + { m_Quicklook = ql; m_QuicklookRenderingFilter->SetInput(m_Quicklook); - } - + } + } itkGetObjectMacro(Quicklook,ImageType); @@ -117,13 +117,13 @@ public: /** Set/Get the rendering function */ void SetRenderingFunction(RenderingFunctionType * function) { - if(m_RenderingFunction != function) - { + if (m_RenderingFunction != function) + { m_RenderingFunction = function; m_QuicklookRenderingFilter->SetRenderingFunction(m_RenderingFunction); m_ExtractRenderingFilter->SetRenderingFunction(m_RenderingFunction); m_ScaledExtractRenderingFilter->SetRenderingFunction(m_RenderingFunction); - } + } } itkGetObjectMacro(RenderingFunction,RenderingFunctionType); @@ -139,10 +139,10 @@ public: /** Set/Get the auto min/max quantile */ void SetAutoMinMaxQuantile(double value) { - if(value < 0. || value > 1.) - { + if (value < 0. || value > 1.) + { itkExceptionMacro(<<"MinMax quantile should be in the range [0,1]"); - } + } m_AutoMinMaxQuantile = value; m_AutoMinMaxUpToDate = false; } @@ -152,30 +152,30 @@ public: virtual void SetExtractRegion(const RegionType & region) { // This check should be done in the itk::ExtractImageFilter - if(this->GetExtractRegion() != region) - { + if (this->GetExtractRegion() != region) + { Superclass::SetExtractRegion(region); // SetExtractionRegion throws an exception in case of empty region - if(region.GetNumberOfPixels() > 0) - { - m_ExtractFilter->SetExtractionRegion(region); - } + if (region.GetNumberOfPixels() > 0) + { + m_ExtractFilter->SetExtractionRegion(region); } + } } - - /** Reimplemented to pass the parameter to the extract filter */ + + /** Reimplemented to pass the parameter to the extract filter */ virtual void SetScaledExtractRegion(const RegionType & region) - { + { // This check should be done in the itk::ExtractImageFilter - if(this->GetScaledExtractRegion() != region) - { + if (this->GetScaledExtractRegion() != region) + { Superclass::SetScaledExtractRegion(region); // SetExtractionRegion throws an exception in case of empty region - if(region.GetNumberOfPixels() > 0) - { - m_ScaledExtractFilter->SetExtractionRegion(region); - } + if (region.GetNumberOfPixels() > 0) + { + m_ScaledExtractFilter->SetExtractionRegion(region); } + } } /** Actually render the image */ @@ -188,13 +188,13 @@ protected: ~ImageLayer(); /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const; - + /** Update the histogram */ virtual void RenderHistogram(); /** Update the images */ virtual void RenderImages(); - + /** Auto min/max rendering function setup */ virtual void AutoMinMaxRenderingFunctionSetup(); @@ -204,7 +204,7 @@ private: /** Pointer to the quicklook */ ImagePointerType m_Quicklook; - + /** Pointer to the image */ ImagePointerType m_Image; @@ -213,7 +213,7 @@ private: /** Rendering function */ RenderingFunctionPointerType m_RenderingFunction; - + /** Number of bins for histograms generation */ unsigned int m_NumberOfHistogramBins; @@ -233,7 +233,7 @@ private: ExtractFilterPointerType m_ExtractFilter; ExtractFilterPointerType m_ScaledExtractFilter; -}; // end class +}; // end class } // end namespace otb #ifndef OTB_MANUAL_INSTANTIATION diff --git a/Code/VisuRefac/otbImageLayer.txx b/Code/VisuRefac/otbImageLayer.txx index 8809abaee9..da5082f1a0 100644 --- a/Code/VisuRefac/otbImageLayer.txx +++ b/Code/VisuRefac/otbImageLayer.txx @@ -26,22 +26,22 @@ namespace otb template <class TImage, class TOutputImage> ImageLayer<TImage,TOutputImage> ::ImageLayer() : m_Quicklook(), m_Image(), m_Histogram(), m_RenderingFunction(), - m_NumberOfHistogramBins(255), m_AutoMinMax(true), m_AutoMinMaxUpToDate(false), m_AutoMinMaxQuantile(0.02), - m_QuicklookRenderingFilter(), m_ExtractRenderingFilter(), m_ScaledExtractRenderingFilter(), - m_ExtractFilter(), m_ScaledExtractFilter() + m_NumberOfHistogramBins(255), m_AutoMinMax(true), m_AutoMinMaxUpToDate(false), m_AutoMinMaxQuantile(0.02), + m_QuicklookRenderingFilter(), m_ExtractRenderingFilter(), m_ScaledExtractRenderingFilter(), + m_ExtractFilter(), m_ScaledExtractFilter() { - // Rendering filters +// Rendering filters m_QuicklookRenderingFilter = RenderingFilterType::New(); - m_ExtractRenderingFilter = RenderingFilterType::New(); + m_ExtractRenderingFilter = RenderingFilterType::New(); m_ScaledExtractRenderingFilter = RenderingFilterType::New(); - + // Default rendering function m_RenderingFunction = DefaultRenderingFunctionType::New(); m_QuicklookRenderingFilter->SetRenderingFunction(m_RenderingFunction); m_ExtractRenderingFilter->SetRenderingFunction(m_RenderingFunction); m_ScaledExtractRenderingFilter->SetRenderingFunction(m_RenderingFunction); - - // Extract filters + + // Extract filters m_ExtractFilter = ExtractFilterType::New(); m_ScaledExtractFilter = ExtractFilterType::New(); @@ -71,12 +71,12 @@ ImageLayer<TImage,TOutputImage> { // Render the histogram this->RenderHistogram(); - + // If required, use histogram for auto min/max - if(m_AutoMinMax) - { + if (m_AutoMinMax) + { this->AutoMinMaxRenderingFunctionSetup(); - } + } // Render images this->RenderImages(); @@ -88,35 +88,35 @@ ImageLayer<TImage,TOutputImage> ::RenderImages() { // Render quicklook - if(this->GetHasQuicklook()) - { + if (this->GetHasQuicklook()) + { m_QuicklookRenderingFilter->Update(); this->SetRenderedQuicklook(m_QuicklookRenderingFilter->GetOutput()); - } + } // If there are pixels to render - if(this->GetExtractRegion().GetNumberOfPixels() > 0) - { + if (this->GetExtractRegion().GetNumberOfPixels() > 0) + { m_ExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetExtractRegion()); m_ExtractRenderingFilter->Update(); this->SetRenderedExtract(m_ExtractRenderingFilter->GetOutput()); - } + } else - { + { this->SetHasExtract(false); - } + } // Render scaled extract // If there are pixels to render - if(this->GetScaledExtractRegion().GetNumberOfPixels() > 0) - { - m_ScaledExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetScaledExtractRegion()); - m_ScaledExtractRenderingFilter->Update(); - this->SetRenderedScaledExtract(m_ScaledExtractRenderingFilter->GetOutput()); - this->SetHasScaledExtract(true); - } + if (this->GetScaledExtractRegion().GetNumberOfPixels() > 0) + { + m_ScaledExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetScaledExtractRegion()); + m_ScaledExtractRenderingFilter->Update(); + this->SetRenderedScaledExtract(m_ScaledExtractRenderingFilter->GetOutput()); + this->SetHasScaledExtract(true); + } else - { + { this->SetHasScaledExtract(false); - } + } } template <class TImage, class TOutputImage> @@ -128,56 +128,56 @@ ImageLayer<TImage,TOutputImage> ImagePointerType histogramSource; // if there is a quicklook, use it for histogram generation - if(m_Quicklook.IsNotNull()) - { + if (m_Quicklook.IsNotNull()) + { histogramSource = m_Quicklook; - } + } else - { + { // Else use the full image (update the data) histogramSource = m_Image; - } + } // Check if we need to generate the histogram again - if( !m_Histogram || (histogramSource->GetUpdateMTime() < histogramSource->GetPipelineMTime()) ) - { + if ( !m_Histogram || (histogramSource->GetUpdateMTime() < histogramSource->GetPipelineMTime()) ) + { m_AutoMinMaxUpToDate = false; // Update the histogram source histogramSource->Update(); - + // Iterate on the image itk::ImageRegionConstIterator<ImageType> it(histogramSource,histogramSource->GetLargestPossibleRegion()); - + // declare a list to store the samples typename ListSampleType::Pointer listSample = ListSampleType::New(); - + // Set the measurement vector size listSample->SetMeasurementVectorSize(histogramSource->GetNumberOfComponentsPerPixel()); - + // Fill the samples list it.GoToBegin(); - while(!it.IsAtEnd()) - { + while (!it.IsAtEnd()) + { listSample->PushBack(it.Get()); ++it; - } - - // Create the histogram generation filter + } + + // Create the histogram generation filter typename HistogramFilterType::Pointer histogramFilter = HistogramFilterType::New(); histogramFilter->SetListSample(listSample); - + typename HistogramFilterType::HistogramSizeType binSizes(histogramSource->GetNumberOfComponentsPerPixel()); binSizes.Fill(m_NumberOfHistogramBins); - + histogramFilter->SetNumberOfBins(binSizes); - + // Generate histogramFilter->Update(); - + // Retrieve the histogram m_Histogram = histogramFilter->GetOutput(); - } + } } template <class TImage, class TOutputImage> @@ -186,21 +186,21 @@ ImageLayer<TImage,TOutputImage> ::AutoMinMaxRenderingFunctionSetup() { // Check for an existing histogram - if(m_Histogram.IsNull()) - { + if (m_Histogram.IsNull()) + { itkExceptionMacro(<<"Empty histogram, can not use auto min/max evaluation."); - } + } const unsigned int nbComps = m_Image->GetNumberOfComponentsPerPixel(); typename RenderingFunctionType::ExtremaVectorType min, max; // For each components, use the histogram to compute min and max - for(unsigned int comp = 0; comp < nbComps;++comp) - { + for (unsigned int comp = 0; comp < nbComps;++comp) + { // Compute quantiles min.push_back(m_Histogram->Quantile(comp,m_AutoMinMaxQuantile)); max.push_back(m_Histogram->Quantile(comp,1.-m_AutoMinMaxQuantile)); - } + } // Setup rendering function m_RenderingFunction->SetMinimum(min); diff --git a/Code/VisuRefac/otbImageLayerGenerator.h b/Code/VisuRefac/otbImageLayerGenerator.h index 949b982aad..7990fada57 100644 --- a/Code/VisuRefac/otbImageLayerGenerator.h +++ b/Code/VisuRefac/otbImageLayerGenerator.h @@ -31,22 +31,22 @@ namespace otb * optionnaly quicklook. * * It ca also suggest a subsampling rate if a user want to generate -* the quicklook by itself. +* the quicklook by itself. * * The output layer can be passed to the AddLayer() method of the * ImageViewerModel. * * It can also be tuned afterward. -* Also it is quite a heavy thing to do, an image layer can still be +* Also it is quite a heavy thing to do, an image layer can still be * built by hands. -* +* * \sa ImageViewerModel * \sa ImageLayer */ -template < class TImageLayer > +template < class TImageLayer > class ImageLayerGenerator - : public itk::Object + : public itk::Object { public: /** Standard class typedefs */ @@ -54,10 +54,10 @@ public: typedef itk::Object Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(ImageLayerGenerator,Object); @@ -73,7 +73,7 @@ public: typedef otb::StreamingShrinkImageFilter <ImageType,ImageType> ResampleFilterType; typedef typename ResampleFilterType::Pointer ResampleFilterPointerType; - + /** Get the generated layer */ itkGetObjectMacro(Layer,ImageLayerType); @@ -114,7 +114,7 @@ protected: /** Generate the layer information */ virtual void GenerateLayerInformation(); - + /** Generate the quicklook (this method is only called if * QuicklookGeneration is on). */ @@ -137,14 +137,14 @@ private: * GenerateQuicklook is on) */ unsigned int m_SubsamplingRate; - + /** if true, the generator will also generate the quicklook */ bool m_GenerateQuicklook; /** Streaming resample filter */ ResampleFilterPointerType m_Resampler; -}; // end class +}; // end class } // end namespace otb #ifndef OTB_MANUAL_INSTANTIATION diff --git a/Code/VisuRefac/otbImageLayerGenerator.txx b/Code/VisuRefac/otbImageLayerGenerator.txx index f3d5f71f6f..10b21294f8 100644 --- a/Code/VisuRefac/otbImageLayerGenerator.txx +++ b/Code/VisuRefac/otbImageLayerGenerator.txx @@ -28,8 +28,8 @@ namespace otb template < class TImageLayer > ImageLayerGenerator<TImageLayer> ::ImageLayerGenerator() : m_Layer(), m_Image(), m_Quicklook(), - m_SubsamplingRate(1), m_GenerateQuicklook(true), - m_Resampler() + m_SubsamplingRate(1), m_GenerateQuicklook(true), + m_Resampler() { // Intialize output layer m_Layer = ImageLayerType::New(); @@ -48,10 +48,10 @@ ImageLayerGenerator<TImageLayer> ::GenerateLayer() { // Check if there is an input image - if(m_Image.IsNull()) - { + if (m_Image.IsNull()) + { return; - } + } // Update image information m_Image->UpdateOutputInformation(); @@ -63,11 +63,11 @@ ImageLayerGenerator<TImageLayer> this->GenerateLayerInformation(); // If we need to generate the quicklook - if(m_GenerateQuicklook) - { + if (m_GenerateQuicklook) + { // Generate it this->GenerateQuicklook(); - } + } } template < class TImageLayer > @@ -76,10 +76,10 @@ ImageLayerGenerator<TImageLayer> ::GetOptimalSubSamplingRate() { // Check if there is an input image - if(m_Image.IsNull()) - { + if (m_Image.IsNull()) + { return 1; - } + } // The optimal rate will be computed according to the screen size. // We want a quality quicklook up to a quarter of the screen. // Get the screen size @@ -104,10 +104,10 @@ ImageLayerGenerator<TImageLayer> unsigned int ratio = std::min(wratio,hratio); // Ensure a non null ratio - if(ratio == 0) - { + if (ratio == 0) + { ratio = 1; - } + } // return the ratio return ratio; } @@ -129,20 +129,20 @@ void ImageLayerGenerator<TImageLayer> ::GenerateQuicklook() { - if(m_GenerateQuicklook) - { + if (m_GenerateQuicklook) + { // Compute optimal subsampling rate unsigned int ssrate = this->GetOptimalSubSamplingRate(); // If no subsampling is needed - if(ssrate == 1) - { + if (ssrate == 1) + { m_Layer->SetHasQuicklook(true); m_Layer->SetQuicklookSubsamplingRate(1); m_Layer->SetQuicklook(m_Image); - } + } else - { + { // build the quicklook m_Layer->SetQuicklookSubsamplingRate(ssrate); m_Resampler->SetInput(m_Image); @@ -152,24 +152,24 @@ ImageLayerGenerator<TImageLayer> // Set the quicklook to the layer m_Layer->SetQuicklook(m_Resampler->GetOutput()); m_Layer->SetHasQuicklook(true); - } } + } else - { + { // If there is a quicklook - if(m_Quicklook.IsNotNull()) - { + if (m_Quicklook.IsNotNull()) + { // Set it to the layer m_Layer->SetQuicklook(m_Quicklook); m_Layer->SetQuicklookSubsamplingRate(m_SubsamplingRate); m_Layer->SetHasQuicklook(true); - } + } else - { + { // else there is no quicklook, disable it m_Layer->SetHasQuicklook(false); - } } + } } template < class TImageLayer > diff --git a/Code/VisuRefac/otbImageView.h b/Code/VisuRefac/otbImageView.h index 41186a84b7..d635f8f745 100644 --- a/Code/VisuRefac/otbImageView.h +++ b/Code/VisuRefac/otbImageView.h @@ -27,13 +27,13 @@ namespace otb { /** \class ImageView -* \brief +* \brief * \Todo: Rename ImageViewer when refactoring will be completed. */ template <class TViewerModel > class ImageView - : public ImageViewerModelListener, public itk::Object + : public ImageViewerModelListener, public itk::Object { public: /** Standard class typedefs */ @@ -52,14 +52,14 @@ public: typedef TViewerModel ModelType; typedef typename ModelType::Pointer ModelPointerType; typedef typename ModelType::OutputImageType ImageType; - + /** Controller typedef */ typedef ImageWidgetController ControllerType; typedef typename ControllerType::Pointer ControllerPointerType; - /** Image region typedef */ + /** Image region typedef */ typedef typename ImageType::RegionType RegionType; - + /** Region size & index typedef */ typedef typename RegionType::SizeType SizeType; typedef typename RegionType::IndexType IndexType; @@ -69,16 +69,16 @@ public: typedef typename ImageWidgetType::Pointer ImageWidgetPointerType; /** - * This method unregister with previous model if any, and + * This method unregister with previous model if any, and * register with the new one. */ void SetModel(ModelType * model); - + /** * This method sets the controller and passes it to the widgets. */ void SetController(ControllerType * controller); - + /** * Manually trigger a refresh */ @@ -89,7 +89,7 @@ public: itkGetObjectMacro(FullWidget,ImageWidgetType); itkGetObjectMacro(ZoomWidget,ImageWidgetType); - protected: +protected: /** Constructor */ ImageView(); /** Destructor */ @@ -108,7 +108,7 @@ public: /** Handle notification from the viewer */ virtual void ImageViewerNotify(); - + private: ImageView(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented diff --git a/Code/VisuRefac/otbImageView.txx b/Code/VisuRefac/otbImageView.txx index 60033ca1f6..b70aa97530 100644 --- a/Code/VisuRefac/otbImageView.txx +++ b/Code/VisuRefac/otbImageView.txx @@ -25,7 +25,7 @@ namespace otb template < class TInputImage > ImageView<TInputImage> ::ImageView() : m_ScrollWidget(), m_FullWidget(), m_ZoomWidget(), - m_Model(), m_Controller() + m_Model(), m_Controller() { // Initializing the widgets m_ScrollWidget = ImageWidgetType::New(); @@ -42,7 +42,7 @@ template < class TInputImage > ImageView<TInputImage> ::~ImageView() { - + } template < class TInputImage > @@ -51,11 +51,11 @@ ImageView<TInputImage> ::SetModel(ModelType * model) { // Unregister from previous model if nay - if(m_Model.IsNotNull()) - { + if (m_Model.IsNotNull()) + { m_Model->UnRegisterListener(this); - } - + } + // Set and register with new model m_Model = model; m_Model->RegisterListener(this); @@ -106,11 +106,11 @@ ImageView<TInputImage> ::UpdateScrollWidget() { // If the model has a quicklook - if(m_Model->GetHasQuicklook()) - { + if (m_Model->GetHasQuicklook()) + { // Read the buffer const RegionType qlRegion = m_Model->GetRasterizedQuicklook() - ->GetLargestPossibleRegion(); + ->GetLargestPossibleRegion(); m_ScrollWidget->ReadBuffer(m_Model->GetRasterizedQuicklook(),qlRegion); // Compute the appropriate scale @@ -126,19 +126,19 @@ ImageView<TInputImage> m_ScrollWidget->label(label.c_str()); // display the zoom rectangle if necessary - if(m_Model->GetHasExtract()) - { + if (m_Model->GetHasExtract()) + { m_ScrollWidget->SetDisplayRectangle(true); m_ScrollWidget->SetRectangle(m_Model->GetSubsampledExtractRegion()); - } + } else - { + { m_ScrollWidget->SetDisplayRectangle(false); - } } + } - // Redraw - m_ScrollWidget->redraw(); + // Redraw + m_ScrollWidget->redraw(); } @@ -147,41 +147,41 @@ void ImageView<TInputImage> ::UpdateFullWidget() { - if(m_Model->GetHasExtract()) - { + if (m_Model->GetHasExtract()) + { m_FullWidget->ReadBuffer(m_Model->GetRasterizedExtract(),m_Model->GetRasterizedExtract() - ->GetLargestPossibleRegion()); + ->GetLargestPossibleRegion()); - // Setting widget label + // Setting widget label std::string label = m_FullWidget->GetIdentifier(); label+=(" - "); label+=m_Model->GetName(); m_FullWidget->label(label.c_str()); // display the zoom rectangle if necessary - if(m_Model->GetHasScaledExtract()) - { + if (m_Model->GetHasScaledExtract()) + { m_FullWidget->SetDisplayRectangle(true); m_FullWidget->SetRectangle(m_Model->GetScaledExtractRegion()); - } + } else - { + { m_FullWidget->SetDisplayRectangle(false); - } + } // redraw the widget m_FullWidget->redraw(); - } - } + } +} template < class TInputImage > void ImageView<TInputImage> ::UpdateZoomWidget() { - if(m_Model->GetHasScaledExtract()) - { + if (m_Model->GetHasScaledExtract()) + { m_ZoomWidget->ReadBuffer(m_Model->GetRasterizedScaledExtract(),m_Model->GetRasterizedScaledExtract() - ->GetLargestPossibleRegion()); + ->GetLargestPossibleRegion()); // Setting widget label std::string label = m_ZoomWidget->GetIdentifier(); @@ -190,7 +190,7 @@ ImageView<TInputImage> m_ZoomWidget->label(label.c_str()); m_ZoomWidget->redraw(); - } + } } diff --git a/Code/VisuRefac/otbImageViewerModel.h b/Code/VisuRefac/otbImageViewerModel.h index ea46a9b0a1..01eb70ec73 100644 --- a/Code/VisuRefac/otbImageViewerModel.h +++ b/Code/VisuRefac/otbImageViewerModel.h @@ -32,15 +32,15 @@ namespace otb * Each visible layer is rendered separately, and the resulting * rendered layers are rasterized using the blending function * associated to each layer. -* +* * \sa Layer * \sa BlendingFunction * */ -template <class TOutputImage = otb::Image<itk::RGBPixel<unsigned char>,2 > > +template <class TOutputImage = otb::Image<itk::RGBPixel<unsigned char>,2 > > class ImageViewerModel - : public MVCModel<ImageViewerModelListener> + : public MVCModel<ImageViewerModelListener> { public: /** Standard class typedefs */ @@ -48,7 +48,7 @@ public: typedef MVCModel<ImageViewerModelListener> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Runtime information */ itkTypeMacro(ImageViewerModel,MVCModel); @@ -58,12 +58,12 @@ public: /** Output image typedef */ typedef TOutputImage OutputImageType; typedef typename OutputImageType::Pointer OutputImagePointerType; - + /** Layer typedef */ typedef otb::Layer<OutputImageType> LayerType; typedef typename LayerType::RegionType RegionType; typedef typename RegionType::IndexType IndexType; - + /** Layer list typedef */ typedef otb::ObjectList<LayerType> LayerListType; typedef typename LayerListType::Pointer LayerListPointerType; @@ -117,7 +117,7 @@ public: /** Get/Set the viewer name */ itkGetStringMacro(Name); itkSetStringMacro(Name); - + /** Get the rasterized views */ itkGetObjectMacro(RasterizedQuicklook,OutputImageType); itkGetObjectMacro(RasterizedExtract,OutputImageType); @@ -129,7 +129,7 @@ public: itkGetConstReferenceMacro(ExtractRegion,RegionType); /** Get the extract region in the quicklook space */ itkGetConstReferenceMacro(SubsampledExtractRegion,RegionType); - + /** Set/Get the Scaled Extract Region */ itkSetMacro(ScaledExtractRegion,RegionType); itkGetConstReferenceMacro(ScaledExtractRegion,RegionType); @@ -138,7 +138,7 @@ public: itkGetMacro(HasQuicklook,bool); itkGetMacro(HasExtract,bool); itkGetMacro(HasScaledExtract,bool); - + /** Update will render all visible layers, rasterize all visible * layers and notify all listeners. */ void Update(void); @@ -151,8 +151,8 @@ public: * region */ void SetExtractRegionCenter(const IndexType & index); - /** Change the extract region by giving the subsamppled center - * of the region */ + /** Change the extract region by giving the subsamppled center + * of the region */ void SetExtractRegionSubsampledCenter(const IndexType & index); protected: @@ -165,13 +165,13 @@ protected: void PrintSelf(std::ostream& os, itk::Indent indent) const; /** Renders all visible layers */ - void RenderVisibleLayers(void); + void RenderVisibleLayers(void); /** Rasterize visible layers */ - void RasterizeVisibleLayers(void); + void RasterizeVisibleLayers(void); /** Notify a registered listener */ - void Notify(ListenerType * listener); + void Notify(ListenerType * listener); /** Constrains the given region to the largest possible one. */ RegionType ConstrainRegion(const RegionType & region, const RegionType & largest); @@ -182,7 +182,7 @@ private: /** Viewer name */ std::string m_Name; - + /** Layer list */ LayerListPointerType m_Layers; @@ -203,7 +203,7 @@ private: /** Wether the model is currently updating or not */ bool m_Updating; -}; // end class +}; // end class } // end namespace otb #ifndef OTB_MANUAL_INSTANTIATION diff --git a/Code/VisuRefac/otbImageViewerModel.txx b/Code/VisuRefac/otbImageViewerModel.txx index ef0d218bec..1765f75a9a 100644 --- a/Code/VisuRefac/otbImageViewerModel.txx +++ b/Code/VisuRefac/otbImageViewerModel.txx @@ -25,16 +25,16 @@ namespace otb template <class TOutputImage> ImageViewerModel<TOutputImage> -::ImageViewerModel() : m_Name("Default"), m_Layers(), m_RasterizedQuicklook(), - m_HasQuicklook(false),m_RasterizedExtract(),m_HasExtract(false), - m_ExtractRegion(), m_SubsampledExtractRegion(), m_RasterizedScaledExtract(), m_HasScaledExtract(false), - m_ScaledExtractRegion() +::ImageViewerModel() : m_Name("Default"), m_Layers(), m_RasterizedQuicklook(), + m_HasQuicklook(false),m_RasterizedExtract(),m_HasExtract(false), + m_ExtractRegion(), m_SubsampledExtractRegion(), m_RasterizedScaledExtract(), m_HasScaledExtract(false), + m_ScaledExtractRegion() { // Intializing the layer list m_Layers = LayerListType::New(); - + } template <class TOutputImage> @@ -61,14 +61,14 @@ ImageViewerModel<TOutputImage> ::GetLayer(unsigned int index) { // Check if not out of bound and return the ith element - if(index >= m_Layers->Size()) - { + if (index >= m_Layers->Size()) + { return NULL; - } + } else - { + { return m_Layers->GetNthElement(index); - } + } } template <class TOutputImage> bool @@ -76,15 +76,15 @@ ImageViewerModel<TOutputImage> ::DeleteLayer(unsigned int index) { // Check if not out of bound and delete the ith element - if(index >= m_Layers->Size()) - { + if (index >= m_Layers->Size()) + { return false; - } + } else - { + { m_Layers->Erase(index); return true; - } + } } template <class TOutputImage> @@ -98,14 +98,14 @@ ImageViewerModel<TOutputImage> bool found = false; // Look for the layer named after name - while(it!=m_Layers->End() && !found) + while (it!=m_Layers->End() && !found) + { + if (it.Get()->GetName() == name) { - if(it.Get()->GetName() == name) - { resp = it.Get(); found = true; - } } + } return resp; } @@ -119,19 +119,19 @@ ImageViewerModel<TOutputImage> unsigned int index = 0; // Look for the layer named after name - while(it!=m_Layers->End() && !found) + while (it!=m_Layers->End() && !found) + { + if (it.Get()->GetName() == name) { - if(it.Get()->GetName() == name) - { found = true; - } - ++index; } - - if(found) - { + ++index; + } + + if (found) + { m_Layers->Erase(index-1); - } + } return found; } @@ -160,8 +160,8 @@ ImageViewerModel<TOutputImage> ::Update() { // Multiple concurrent update guards - if(!m_Updating) - { + if (!m_Updating) + { m_Updating = true; // Render all visible layers this->RenderVisibleLayers(); @@ -170,7 +170,7 @@ ImageViewerModel<TOutputImage> // Notify all listeners this->NotifyAll(); m_Updating = false; - } + } } template <class TOutputImage> @@ -179,12 +179,12 @@ ImageViewerModel<TOutputImage> ::RenderVisibleLayers() { // Render all visible layers - for(LayerIteratorType it = m_Layers->Begin(); - it != m_Layers->End(); ++it) - { + for (LayerIteratorType it = m_Layers->Begin(); + it != m_Layers->End(); ++it) + { // If the layer is visible - if(it.Get()->GetVisible()) - { + if (it.Get()->GetVisible()) + { // Set the extracted region m_ExtractRegion = this->ConstrainRegion(m_ExtractRegion,it.Get()->GetExtent()); it.Get()->SetExtractRegion(m_ExtractRegion); @@ -193,8 +193,8 @@ ImageViewerModel<TOutputImage> it.Get()->SetScaledExtractRegion(m_ScaledExtractRegion); // Render it it.Get()->Render(); - } } + } } template <class TOutputImage> @@ -203,29 +203,29 @@ ImageViewerModel<TOutputImage> ::RasterizeVisibleLayers() { // If there are no layer to render - if(this->GetNumberOfLayers() == 0) - { + if (this->GetNumberOfLayers() == 0) + { // Ensure nothing is available m_HasQuicklook = false; m_HasExtract = false; m_HasScaledExtract = false; // and return without doing anything return; - } - + } + // Get the lowest layer LayerIteratorType it = m_Layers->Begin(); - + // Base layer typename LayerType::Pointer baseLayer = it.Get(); - + // Configure base layer rasterization - if(baseLayer->GetHasQuicklook()) - { + if (baseLayer->GetHasQuicklook()) + { m_HasQuicklook = true; m_RasterizedQuicklook = baseLayer->GetRenderedQuicklook(); - - // Update the subsampled extract region + + // Update the subsampled extract region m_SubsampledExtractRegion = m_ExtractRegion; typename RegionType::SizeType size = m_SubsampledExtractRegion.GetSize(); typename RegionType::IndexType index = m_SubsampledExtractRegion.GetIndex(); @@ -235,73 +235,73 @@ ImageViewerModel<TOutputImage> index[1]/=baseLayer->GetQuicklookSubsamplingRate(); m_SubsampledExtractRegion.SetIndex(index); m_SubsampledExtractRegion.SetSize(size); - } + } - if(baseLayer->GetHasExtract()) - { + if (baseLayer->GetHasExtract()) + { m_HasExtract = true; m_RasterizedExtract = baseLayer->GetRenderedExtract(); - } + } - if(baseLayer->GetHasScaledExtract()) - { + if (baseLayer->GetHasScaledExtract()) + { m_HasScaledExtract = true; m_RasterizedScaledExtract = baseLayer->GetRenderedScaledExtract(); - } + } // Move to the next layer ++it; - + // Walk the remaining layers - while(it!=m_Layers->End()) - { + while (it!=m_Layers->End()) + { // If a layer is visible - if(it.Get()->GetVisible()) + if (it.Get()->GetVisible()) + { + // If quicklook is activated and available for this layer + if (m_HasQuicklook && it.Get()->GetHasQuicklook()) { - // If quicklook is activated and available for this layer - if(m_HasQuicklook && it.Get()->GetHasQuicklook()) - { // Blend it with the current rasterized quicklook - typename BlendingFilterType::Pointer blender = BlendingFilterType::New(); - // Using the blending function of the layer - blender->SetBlendingFunction(it.Get()->GetBlendingFunction()); - blender->SetInput1(m_RasterizedQuicklook); - blender->SetInput2(it.Get()->GetRenderedQuicklook()); - blender->Update(); - // Store the result as being the current rasterized quicklook - m_RasterizedQuicklook = blender->GetOutput(); - } - - // If extract is activated and available for this layer - if(m_HasExtract && it.Get()->GetHasExtract()) - { + typename BlendingFilterType::Pointer blender = BlendingFilterType::New(); + // Using the blending function of the layer + blender->SetBlendingFunction(it.Get()->GetBlendingFunction()); + blender->SetInput1(m_RasterizedQuicklook); + blender->SetInput2(it.Get()->GetRenderedQuicklook()); + blender->Update(); + // Store the result as being the current rasterized quicklook + m_RasterizedQuicklook = blender->GetOutput(); + } + + // If extract is activated and available for this layer + if (m_HasExtract && it.Get()->GetHasExtract()) + { // Blend it with the current rasterized extract - typename BlendingFilterType::Pointer blender = BlendingFilterType::New(); - // Using the blending function of the layer - blender->SetBlendingFunction(it.Get()->GetBlendingFunction()); - blender->SetInput1(m_RasterizedExtract); - blender->SetInput2(it.Get()->GetRenderedExtract()); - blender->Update(); - // Store the result as being the current rasterized extract - m_RasterizedExtract = blender->GetOutput(); - } - - // If scaledExtract is activated and available for this layer - if(m_HasScaledExtract && it.Get()->GetHasScaledExtract()) - { - // Blend it with the current rasterized scaledExtract - typename BlendingFilterType::Pointer blender = BlendingFilterType::New(); - // Using the blending function of the layer - blender->SetBlendingFunction(it.Get()->GetBlendingFunction()); - blender->SetInput1(m_RasterizedScaledExtract); - blender->SetInput2(it.Get()->GetRenderedScaledExtract()); - blender->Update(); - // Store the result as being the current rasterized scaledExtract - m_RasterizedScaledExtract = blender->GetOutput(); - } + typename BlendingFilterType::Pointer blender = BlendingFilterType::New(); + // Using the blending function of the layer + blender->SetBlendingFunction(it.Get()->GetBlendingFunction()); + blender->SetInput1(m_RasterizedExtract); + blender->SetInput2(it.Get()->GetRenderedExtract()); + blender->Update(); + // Store the result as being the current rasterized extract + m_RasterizedExtract = blender->GetOutput(); + } + + // If scaledExtract is activated and available for this layer + if (m_HasScaledExtract && it.Get()->GetHasScaledExtract()) + { + // Blend it with the current rasterized scaledExtract + typename BlendingFilterType::Pointer blender = BlendingFilterType::New(); + // Using the blending function of the layer + blender->SetBlendingFunction(it.Get()->GetBlendingFunction()); + blender->SetInput1(m_RasterizedScaledExtract); + blender->SetInput2(it.Get()->GetRenderedScaledExtract()); + blender->Update(); + // Store the result as being the current rasterized scaledExtract + m_RasterizedScaledExtract = blender->GetOutput(); } - ++it; } + ++it; + } } template <class TOutputImage> @@ -356,7 +356,7 @@ ImageViewerModel<TOutputImage> IndexType newIndex = index; newIndex[0]*= baseLayer->GetQuicklookSubsamplingRate(); newIndex[1]*= baseLayer->GetQuicklookSubsamplingRate(); - + // Update Scaled extract center as well this->SetScaledExtractRegionCenter(newIndex); @@ -377,28 +377,28 @@ ImageViewerModel<TOutputImage> if (small.GetSize()[0]>big.GetSize()[0] ||small.GetSize()[1]>big.GetSize()[1]) { - resp.Crop(big); + resp.Crop(big); } else { - // Else we can constrain it + // Else we can constrain it IndexType index = resp.GetIndex(); typename RegionType::SizeType size = resp.GetSize(); // For each dimension - for(unsigned int dim = 0; dim < RegionType::ImageDimension; ++dim) - { + for (unsigned int dim = 0; dim < RegionType::ImageDimension; ++dim) + { // push left if necessary if (small.GetIndex()[dim]<big.GetIndex()[dim]) - { - index[dim]=big.GetIndex()[dim]; - } + { + index[dim]=big.GetIndex()[dim]; + } // push right if necessary if (index[dim]+size[dim]>=big.GetIndex()[dim]+big.GetSize()[dim]) - { - index[dim]=big.GetIndex()[dim]+big.GetSize()[dim]-size[dim]; - } + { + index[dim]=big.GetIndex()[dim]+big.GetSize()[dim]-size[dim]; } + } resp.SetSize(size); resp.SetIndex(index); } @@ -413,13 +413,13 @@ ImageViewerModel<TOutputImage> // Call superclass implementation Superclass::PrintSelf(os,indent); os<<indent<<"Viewer "<<m_Name<<": "<<std::endl; - for(LayerIteratorType it = m_Layers->Begin(); - it != m_Layers->End(); ++it) - { + for (LayerIteratorType it = m_Layers->Begin(); + it != m_Layers->End(); ++it) + { os<<indent<<it.Get()<<std::endl; - } + } } } // end namespace otb -#endif +#endif diff --git a/Code/VisuRefac/otbImageWidget.h b/Code/VisuRefac/otbImageWidget.h index 931b690fc5..a7637e3937 100644 --- a/Code/VisuRefac/otbImageWidget.h +++ b/Code/VisuRefac/otbImageWidget.h @@ -44,13 +44,13 @@ namespace otb * will generate an exception. * Using Gl acceleration allows you to have a better rendering when * zooming. -* +* * It is also able to display a rectangle on the displayed image. */ template <class TInputImage=otb::Image<itk::RGBPixel<unsigned char>,2 > > class ImageWidget - : public Fl_Gl_Window, public itk::Object + : public Fl_Gl_Window, public itk::Object { public: /** Standard class typedefs */ @@ -110,7 +110,7 @@ public: itkSetMacro(DisplayRectangle,bool); itkGetMacro(DisplayRectangle,bool); itkBooleanMacro(DisplayRectangle); - + /** Set/Get the rectangle to display */ itkSetMacro(Rectangle,RegionType); itkGetConstReferenceMacro(Rectangle,RegionType); @@ -125,7 +125,7 @@ public: /** Convert a screen index to a buffered region index */ IndexType ScreenIndexToRegionIndex(const IndexType& index ); - + /** Convert a buffered region index to a screen index */ IndexType RegionIndexToScreenIndex(const IndexType& index); @@ -192,7 +192,7 @@ private: RegionType m_Rectangle; bool m_DisplayRectangle; ColorType m_RectangleColor; - + /** Image extent coordinates in the display axis system */ double m_ImageExtentWidth; double m_ImageExtentHeight; diff --git a/Code/VisuRefac/otbImageWidget.txx b/Code/VisuRefac/otbImageWidget.txx index 71f605a92e..2e3a65f075 100644 --- a/Code/VisuRefac/otbImageWidget.txx +++ b/Code/VisuRefac/otbImageWidget.txx @@ -26,13 +26,13 @@ namespace otb template <class TInputImage> ImageWidget<TInputImage> ::ImageWidget() : Fl_Gl_Window(0,0,0,0), m_IsotropicZoom(1.0), m_OpenGlBuffer(NULL), m_OpenGlBufferedRegion(), - m_Identifier("Default"), m_UseGlAcceleration(false), m_Rectangle(),m_DisplayRectangle(false), - m_RectangleColor(), m_ImageExtentWidth(0), m_ImageExtentHeight(0), m_ImageExtentX(), m_ImageExtentY() + m_Identifier("Default"), m_UseGlAcceleration(false), m_Rectangle(),m_DisplayRectangle(false), + m_RectangleColor(), m_ImageExtentWidth(0), m_ImageExtentHeight(0), m_ImageExtentX(), m_ImageExtentY() { - #ifdef OTB_GL_USE_ACCEL +#ifdef OTB_GL_USE_ACCEL m_UseGlAcceleration = true; - #endif - +#endif + // Default color for rectangle m_RectangleColor.Fill(0.); m_RectangleColor[0]=1.0; @@ -44,11 +44,11 @@ ImageWidget<TInputImage> ::~ImageWidget() { // Delete OpenGl buffer if needed - if(m_OpenGlBuffer!=NULL) - { + if (m_OpenGlBuffer!=NULL) + { delete [] m_OpenGlBuffer; m_OpenGlBuffer = NULL; - } + } } template <class TInputImage> @@ -60,26 +60,26 @@ ImageWidget<TInputImage> Superclass::PrintSelf(os,indent); // Display information about the widget os<<indent<<"Widget "<<m_Identifier<<": "<<std::endl; - #ifndef OTB_GL_USE_ACCEL +#ifndef OTB_GL_USE_ACCEL os<<indent<<indent<<"OpenGl acceleration is not allowed."<<std::endl; - #else - if(m_UseGlAcceleration) - { +#else + if (m_UseGlAcceleration) + { os<<indent<<indent<<"OpenGl acceleration is allowed and enabled."<<std::endl; - } + } else - { + { os<<indent<<indent<<"OpenGl acceleration is allowed but disabled."<<std::endl; - } - #endif - if(m_OpenGlBuffer == NULL) - { + } +#endif + if (m_OpenGlBuffer == NULL) + { os<<indent<<indent<<"OpenGl buffer is not allocated."<<std::endl; - } + } else - { + { os<<indent<<indent<<"OpenGl buffer is allocated with size "<<m_OpenGlBufferedRegion.GetSize()<<"."<<std::endl; - } + } os<<indent<<indent<<"OpenGl isotropic zoom is "<<m_IsotropicZoom<<"."<<std::endl; } @@ -92,24 +92,24 @@ ImageWidget<TInputImage> { // Before doing anything, check if region is inside the buffered // region of image - if(!image->GetBufferedRegion().IsInside(region)) - { + if (!image->GetBufferedRegion().IsInside(region)) + { itkExceptionMacro(<<"Region to read is oustside of the buffered region."); - } + } // Check if Gl acceleration mode is correct - #ifndef OTB_GL_USE_ACCEL - if(m_UseGlAcceleration) - { +#ifndef OTB_GL_USE_ACCEL + if (m_UseGlAcceleration) + { itkExceptionMacro(<<"Gl acceleration enabled but not allowed. Consider rebuilding with OTB_USE_GL_ACCEL to ON."); - } - #endif + } +#endif // Delete previous buffer if needed - if(m_OpenGlBuffer != NULL) - { + if (m_OpenGlBuffer != NULL) + { delete [] m_OpenGlBuffer; m_OpenGlBuffer = NULL; - } + } // Allocate new memory m_OpenGlBuffer = new unsigned char[3*region.GetNumberOfPixels()]; @@ -119,28 +119,28 @@ ImageWidget<TInputImage> // Go to begin it.GoToBegin(); - while(!it.IsAtEnd()) - { + while (!it.IsAtEnd()) + { // Fill the buffer unsigned int index = 0; - if(!m_UseGlAcceleration) - { + if (!m_UseGlAcceleration) + { // compute the linear index (buffer is flipped around X axis // when gl acceleration is disabled index = ComputeXAxisFlippedBufferIndex(it.GetIndex(),region); - } + } else - { + { // Conpute the linear index index = ComputeBufferIndex(it.GetIndex(),region); - } + } // Fill the buffer m_OpenGlBuffer[index] =it.Get()[0]; m_OpenGlBuffer[index+1]=it.Get()[1]; m_OpenGlBuffer[index+2]=it.Get()[2]; ++it; - } + } // Last, updating buffer size m_OpenGlBufferedRegion = region; } @@ -151,13 +151,13 @@ ImageWidget<TInputImage> ::draw() { // Check if Gl acceleration mode is correct - #ifndef OTB_GL_USE_ACCEL - if(m_UseGlAcceleration) - { +#ifndef OTB_GL_USE_ACCEL + if (m_UseGlAcceleration) + { itkWarningMacro(<<"Gl acceleration enabled but not allowed. Consider rebuilding with OTB_USE_GL_ACCEL to ON. For now, disabling Gl acceleration."); m_UseGlAcceleration=false; - } - #endif + } +#endif // Set up Gl environement if (!this->valid()) @@ -177,10 +177,10 @@ ImageWidget<TInputImage> this->ortho(); glDisable(GL_BLEND); // Check if there is somthing to draw - if(m_OpenGlBuffer == NULL) - { + if (m_OpenGlBuffer == NULL) + { return; - } + } // Image extent m_ImageExtentWidth = m_IsotropicZoom*static_cast<double>(m_OpenGlBufferedRegion.GetSize()[0]); @@ -188,21 +188,21 @@ ImageWidget<TInputImage> m_ImageExtentX = (static_cast<double>(this->w())-m_ImageExtentWidth)/2; m_ImageExtentY = (static_cast<double>(this->h())-m_ImageExtentHeight)/2; - if(!m_UseGlAcceleration) - { + if (!m_UseGlAcceleration) + { // Set the pixel Zoom glRasterPos2f(m_ImageExtentX,m_ImageExtentY); glPixelZoom(m_IsotropicZoom,m_IsotropicZoom); // display the image glDrawPixels(m_OpenGlBufferedRegion.GetSize()[0], - m_OpenGlBufferedRegion.GetSize()[1], - GL_RGB, - GL_UNSIGNED_BYTE, - m_OpenGlBuffer); - } + m_OpenGlBufferedRegion.GetSize()[1], + GL_RGB, + GL_UNSIGNED_BYTE, + m_OpenGlBuffer); + } else - { + { glEnable(GL_TEXTURE_2D); glColor4f(1.0,1.0,1.0,0.0); GLuint texture; @@ -223,11 +223,11 @@ ImageWidget<TInputImage> glVertex3f (m_ImageExtentX,m_ImageExtentY+m_ImageExtentHeight, 0.0); glEnd (); glDisable(GL_TEXTURE_2D); - } + } // Draw the rectangle if necessary - if(m_DisplayRectangle) - { + if (m_DisplayRectangle) + { typename RegionType::IndexType index; typename RegionType::SizeType size; @@ -236,19 +236,19 @@ ImageWidget<TInputImage> // the real upper left index[1]+=m_Rectangle.GetSize()[1]; index = RegionIndexToScreenIndex(index); - + size[0]= static_cast<unsigned int>(static_cast<double>(m_Rectangle.GetSize()[0])*m_IsotropicZoom); size[1] = static_cast<unsigned int>(static_cast<double>(m_Rectangle.GetSize()[1])*m_IsotropicZoom); - + glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(m_RectangleColor[0],m_RectangleColor[1],m_RectangleColor[2],m_RectangleColor[3]); glBegin(GL_LINE_LOOP); gl_rect(index[0],index[1],size[0],size[1]); glEnd(); glDisable(GL_BLEND); - } + } } template <class TInputImage> @@ -258,33 +258,33 @@ ImageWidget<TInputImage> { // Distinguish between resize, move and not changed events // (The system window manager may generate multiple resizing events, - // so we'd rather avoid event flooding here) + // so we'd rather avoid event flooding here) bool reportMove = false; bool reportResize = false; - if(this->x() != x || this->y() != y) - { + if (this->x() != x || this->y() != y) + { reportMove = true; - } + } - if(this->w() != w || this->h() != h) - { + if (this->w() != w || this->h() != h) + { reportResize = true; - } + } // First call the superclass implementation Fl_Gl_Window::resize(x,y,w,h); // If There is a controller - if(m_Controller.IsNotNull()) + if (m_Controller.IsNotNull()) + { + if (reportMove) { - if(reportMove) - { m_Controller->HandleWidgetMove(m_Identifier,x,y); - } - if(reportResize) - { + } + if (reportResize) + { m_Controller->HandleWidgetResize(m_Identifier,w,h); - } } + } } template <class TInputImage> @@ -293,14 +293,14 @@ ImageWidget<TInputImage> ::handle(int event) { // If there is a controller - if(m_Controller.IsNotNull()) - { + if (m_Controller.IsNotNull()) + { return m_Controller->HandleWidgetEvent(m_Identifier,event); - } + } else - { + { return 0; - } + } } template <class TInputImage> @@ -309,7 +309,7 @@ typename ImageWidget<TInputImage> ImageWidget<TInputImage> ::ScreenIndexToRegionIndex(const IndexType & index) { - IndexType resp; + IndexType resp; resp[0] = static_cast<int>(m_OpenGlBufferedRegion.GetIndex()[0]+static_cast<double>(index[0]-m_ImageExtentX)/m_IsotropicZoom); resp[1] = static_cast<int>(m_OpenGlBufferedRegion.GetIndex()[1]+static_cast<double>(index[1]-m_ImageExtentY)/m_IsotropicZoom); return resp; @@ -324,7 +324,7 @@ ImageWidget<TInputImage> IndexType resp; resp[0]=static_cast<int>(m_ImageExtentX+(index[0]-m_OpenGlBufferedRegion.GetIndex()[0])*m_IsotropicZoom); resp[1]=static_cast<int>(m_ImageExtentY+m_ImageExtentHeight-(index[1]-m_OpenGlBufferedRegion.GetIndex()[1])*m_IsotropicZoom); - return resp; + return resp; } } diff --git a/Code/VisuRefac/otbImageWidgetActionHandler.h b/Code/VisuRefac/otbImageWidgetActionHandler.h index 94cc8c0487..8ec0d3bee9 100644 --- a/Code/VisuRefac/otbImageWidgetActionHandler.h +++ b/Code/VisuRefac/otbImageWidgetActionHandler.h @@ -29,13 +29,13 @@ namespace otb * To implement a new action handler, derive this class and implement * the ListenTo*() and the HandleWidget*() methods. Then register an * instance of your handler in the ImageWidgetController. -* +* * \sa ImageWidgetController * \sa ImageWidget */ class ImageWidgetActionHandler - : public itk::Object + : public itk::Object { public: /** Standard class typedefs */ @@ -43,10 +43,10 @@ public: typedef itk::Object Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(ImageWidgetActionHandler,Object); @@ -71,32 +71,32 @@ public: return false; } - /** Handle widget resize - * \param widgetId The id of the resized widget - * \param w new width - * \param h new height - * \return true if the event is handled - */ + /** Handle widget resize + * \param widgetId The id of the resized widget + * \param w new width + * \param h new height + * \return true if the event is handled + */ virtual bool HandleWidgetResize(std::string widgetId,int w, int h) { return false; } - + protected: /** Constructor */ - ImageWidgetActionHandler(){} + ImageWidgetActionHandler() {} /** Destructor */ - virtual ~ImageWidgetActionHandler(){} + virtual ~ImageWidgetActionHandler() {} /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os,indent); } - + private: ImageWidgetActionHandler(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented -}; // end class +}; // end class } // end namespace otb #endif diff --git a/Code/VisuRefac/otbImageWidgetController.cxx b/Code/VisuRefac/otbImageWidgetController.cxx index 5955226562..f81b8746d5 100644 --- a/Code/VisuRefac/otbImageWidgetController.cxx +++ b/Code/VisuRefac/otbImageWidgetController.cxx @@ -60,65 +60,65 @@ int ImageWidgetController::HandleWidgetEvent(std::string widgetId, int event) // The action handler found ActionHandlerType * handler; - while(!found && it!=m_ActionHandlersList->End()) - { + while (!found && it!=m_ActionHandlersList->End()) + { // Get the current handler handler = it.Get(); // Check if it listens to (widget,event) found = handler->HandleWidgetEvent(widgetId,event); ++it; - } + } // If an handler was found, use it - if(found) - { + if (found) + { return 1; - } + } else - { + { return 0; - } + } } void ImageWidgetController::HandleWidgetResize(std::string widgetId, int w, int h) { // Define an iterator on the action handlers list ActionHandlerListType::Iterator it = m_ActionHandlersList->Begin(); - + // Found indicates if a handler was found to respond to this event bool found = false; // The action handler found ActionHandlerType * handler; - while(!found && it!=m_ActionHandlersList->End()) - { + while (!found && it!=m_ActionHandlersList->End()) + { // Get the current handler handler = it.Get(); // try to handle the event with the current handler found = handler->HandleWidgetResize(widgetId,w,h); ++it; - } + } } void ImageWidgetController::HandleWidgetMove(std::string widgetId, int x, int y) { // Define an iterator on the action handlers list ActionHandlerListType::Iterator it = m_ActionHandlersList->Begin(); - + // Found indicates if a handler was found to respond to this event bool found = false; // The action handler found ActionHandlerType * handler; - while(!found && it!=m_ActionHandlersList->End()) - { + while (!found && it!=m_ActionHandlersList->End()) + { // Get the current handler handler = it.Get(); // Check if it listens to (widget,event) found = handler->HandleWidgetMove(widgetId,x,y); ++it; - } + } } @@ -130,5 +130,5 @@ void ImageWidgetController::PrintSelf(std::ostream& os, itk::Indent indent) cons } // end namespace otb - + #endif diff --git a/Code/VisuRefac/otbImageWidgetController.h b/Code/VisuRefac/otbImageWidgetController.h index 1767a5623a..2c40de6371 100644 --- a/Code/VisuRefac/otbImageWidgetController.h +++ b/Code/VisuRefac/otbImageWidgetController.h @@ -34,7 +34,7 @@ namespace otb */ class ImageWidgetController - : public itk::Object + : public itk::Object { public: /** Standard class typedefs */ @@ -42,10 +42,10 @@ public: typedef itk::Object Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(ImageWidgetController,Object); @@ -68,7 +68,7 @@ public: */ virtual void ClearAllActionHandlers(); - /** Handle an event from a widget + /** Handle an event from a widget * \param widgetId The id of the widget the event comes from * \param event The event code */ @@ -81,11 +81,11 @@ public: */ void HandleWidgetResize(std::string widgetId, int w, int h); - /** Handle widget move - * \param widgetId The id of the resized widget - * \param x new x location - * \param y new y location - */ + /** Handle widget move + * \param widgetId The id of the resized widget + * \param x new x location + * \param y new y location + */ void HandleWidgetMove(std::string widgetId, int x, int y); protected: @@ -95,7 +95,7 @@ protected: ~ImageWidgetController(); /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const; - + private: ImageWidgetController(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented @@ -103,7 +103,7 @@ private: /** Action handlers list */ ActionHandlerListPointerType m_ActionHandlersList; -}; // end class +}; // end class } // end namespace otb #endif diff --git a/Code/VisuRefac/otbLayer.h b/Code/VisuRefac/otbLayer.h index 5c24e1c827..9cdc8be8e3 100644 --- a/Code/VisuRefac/otbLayer.h +++ b/Code/VisuRefac/otbLayer.h @@ -29,13 +29,13 @@ namespace otb /** \class Layer * \brief Base class for all layers objects * A layer is something that can be rendered to the screen. -* +* * \sa ImageViewerModel */ -template <class TOutputImage = Image<itk::RGBPixel<unsigned char>, 2 > > +template <class TOutputImage = Image<itk::RGBPixel<unsigned char>, 2 > > class Layer - : public itk::Object + : public itk::Object { public: /** Standard class typedefs */ @@ -43,7 +43,7 @@ public: typedef itk::Object Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Runtime information */ itkTypeMacro(Layer,Object); @@ -114,17 +114,17 @@ public: protected: /** Constructor */ - Layer() : m_Name("Default"), m_Visible(false), m_Extent(), - m_RenderedQuicklook(), m_HasQuicklook(false), m_QuicklookSize(), m_QuicklookSubsamplingRate(1), - m_RenderedExtract(), m_HasExtract(false), m_ExtractRegion(), - m_RenderedScaledExtract(), m_HasScaledExtract(false), m_ScaledExtractRegion(), - m_BlendingFunction() + Layer() : m_Name("Default"), m_Visible(false), m_Extent(), + m_RenderedQuicklook(), m_HasQuicklook(false), m_QuicklookSize(), m_QuicklookSubsamplingRate(1), + m_RenderedExtract(), m_HasExtract(false), m_ExtractRegion(), + m_RenderedScaledExtract(), m_HasScaledExtract(false), m_ScaledExtractRegion(), + m_BlendingFunction() { // Default blending function m_BlendingFunction = Function::UniformAlphaBlendingFunction<PixelType>::New(); } /** Destructor */ - virtual ~Layer(){} + virtual ~Layer() {} /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const { @@ -149,7 +149,7 @@ private: /** Is the layer visible ? */ bool m_Visible; - + /** Data extent */ RegionType m_Extent; @@ -172,7 +172,7 @@ private: /** Pointer to the blending function */ BlendingFunctionPointerType m_BlendingFunction; -}; // end class +}; // end class } // end namespace otb #endif diff --git a/Code/VisuRefac/otbMultiplyBlendingFunction.h b/Code/VisuRefac/otbMultiplyBlendingFunction.h index 9feca3bfee..51766fb29a 100644 --- a/Code/VisuRefac/otbMultiplyBlendingFunction.h +++ b/Code/VisuRefac/otbMultiplyBlendingFunction.h @@ -31,61 +31,61 @@ namespace Function * For each channel the blending function is as follows: * \f[ P_{o} = P_{i1} * P_{i2} / 255 \f] */ - template <class TInputRGBPixel1, class TInputRGBPixel2 = TInputRGBPixel1, class TOutputRGBPixel = TInputRGBPixel1> - class MultiplyBlendingFunction - : public BlendingFunction<TInputRGBPixel1,TInputRGBPixel2,TOutputRGBPixel> +template <class TInputRGBPixel1, class TInputRGBPixel2 = TInputRGBPixel1, class TOutputRGBPixel = TInputRGBPixel1> +class MultiplyBlendingFunction + : public BlendingFunction<TInputRGBPixel1,TInputRGBPixel2,TOutputRGBPixel> +{ +public: + /** Standard class typedefs */ + typedef MultiplyBlendingFunction Self; + typedef BlendingFunction<TInputRGBPixel1, + TInputRGBPixel2, + TOutputRGBPixel> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** type macro */ + itkTypeMacro(MultiplyBlendingFunction,BlendingFunction); + + /** new macro */ + itkNewMacro(Self); + + /** PixelType macros */ + typedef TInputRGBPixel1 InputPixel1Type; + typedef TInputRGBPixel2 InputPixel2Type; + typedef TOutputRGBPixel OutputRGBPixelType; + typedef typename OutputRGBPixelType::ValueType OutputValueType; + + /** Evaluate method */ + virtual const OutputRGBPixelType Evaluate(const InputPixel1Type& input1, const InputPixel2Type & input2) { - public: - /** Standard class typedefs */ - typedef MultiplyBlendingFunction Self; - typedef BlendingFunction<TInputRGBPixel1, - TInputRGBPixel2, - TOutputRGBPixel> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** type macro */ - itkTypeMacro(MultiplyBlendingFunction,BlendingFunction); - - /** new macro */ - itkNewMacro(Self); - - /** PixelType macros */ - typedef TInputRGBPixel1 InputPixel1Type; - typedef TInputRGBPixel2 InputPixel2Type; - typedef TOutputRGBPixel OutputRGBPixelType; - typedef typename OutputRGBPixelType::ValueType OutputValueType; - - /** Evaluate method */ - virtual const OutputRGBPixelType Evaluate(const InputPixel1Type& input1, const InputPixel2Type & input2) - { - OutputRGBPixelType resp; - resp.SetRed( static_cast<OutputValueType>( - vcl_floor( static_cast<double>(input1.GetRed()) + OutputRGBPixelType resp; + resp.SetRed( static_cast<OutputValueType>( + vcl_floor( static_cast<double>(input1.GetRed()) * static_cast<double>(input2.GetRed())/255 +0.5) - )); - resp.SetGreen(static_cast<OutputValueType>( - vcl_floor( static_cast<double>(input1.GetGreen()) + )); + resp.SetGreen(static_cast<OutputValueType>( + vcl_floor( static_cast<double>(input1.GetGreen()) * static_cast<double>(input2.GetGreen())/255+0.5) - )); - resp.SetBlue( static_cast<OutputValueType>( - vcl_floor( static_cast<double>(input1.GetBlue()) + )); + resp.SetBlue( static_cast<OutputValueType>( + vcl_floor( static_cast<double>(input1.GetBlue()) * static_cast<double>(input2.GetBlue())/255 +0.5) - )); - return resp; - } + )); + return resp; + } - protected: - /** Constructor */ - MultiplyBlendingFunction() {} - /** Destructor */ - ~MultiplyBlendingFunction() {} - private: - MultiplyBlendingFunction(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented +protected: + /** Constructor */ + MultiplyBlendingFunction() {} + /** Destructor */ + ~MultiplyBlendingFunction() {} +private: + MultiplyBlendingFunction(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented - }; +}; } // end namespace Functor } // end namespace otb diff --git a/Code/VisuRefac/otbRenderingFunction.h b/Code/VisuRefac/otbRenderingFunction.h index dc34d91279..684e95d640 100644 --- a/Code/VisuRefac/otbRenderingFunction.h +++ b/Code/VisuRefac/otbRenderingFunction.h @@ -33,7 +33,7 @@ namespace Function */ template <class TPixelPrecision, class TRGBPixel> class RenderingFunction - : public itk::Object + : public itk::Object { public: /** Standard class typedefs */ @@ -51,13 +51,13 @@ public: typedef itk::VariableLengthVector<ScalarPixelType> VectorPixelType; /** Extrema vector */ typedef std::vector<ScalarPixelType> ExtremaVectorType; - + /** Evaluate method (scalar version) */ virtual const OutputPixelType Evaluate(ScalarPixelType spixel) const = 0; /** Evaluate method (vector version) */ virtual const OutputPixelType Evaluate(const VectorPixelType & vpixel) const = 0; - + /** This method is available to allow implementation of * preprocessing. */ @@ -69,32 +69,32 @@ public: m_Minimum.clear(); m_Minimum.push_back(spixel); } - + /** Set the maximum (scalar version) */ virtual void SetMaximum(ScalarPixelType spixel) { m_Maximum.clear(); m_Maximum.push_back(spixel); } - - /** Set minimum (vector version) */ + + /** Set minimum (vector version) */ virtual void SetMinimum(const VectorPixelType & vpixel) { m_Minimum.clear(); - for(unsigned int i = 0; i < vpixel.Size();++i) - { + for (unsigned int i = 0; i < vpixel.Size();++i) + { m_Minimum.push_back(vpixel[i]); - } + } } - + /** Set maximum (vector version) */ virtual void SetMaximum(const VectorPixelType & vpixel) { m_Maximum.clear(); - for(unsigned int i = 0; i < vpixel.Size();++i) - { + for (unsigned int i = 0; i < vpixel.Size();++i) + { m_Maximum.push_back(vpixel[i]); - } + } } /** Set minimum (std::vector version) */ diff --git a/Code/VisuRefac/otbRenderingImageFilter.h b/Code/VisuRefac/otbRenderingImageFilter.h index d57b5e5ace..f087727cee 100644 --- a/Code/VisuRefac/otbRenderingImageFilter.h +++ b/Code/VisuRefac/otbRenderingImageFilter.h @@ -77,7 +77,7 @@ public: } /** Destructor */ - ~RenderingFunctor(){} + ~RenderingFunctor() {} /** Set the rendering function * \param function the Rendering function. @@ -120,18 +120,18 @@ private: */ template <class TInputImage,class TOutputImage = Image<itk::RGBPixel<unsigned char>, 2 > > class RenderingImageFilter - : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, - Functor::RenderingFunctor - < typename TInputImage ::InternalPixelType, - typename TOutputImage::PixelType > > + : public itk::UnaryFunctorImageFilter<TInputImage,TOutputImage, + Functor::RenderingFunctor + < typename TInputImage ::InternalPixelType, + typename TOutputImage::PixelType > > { public: /** Standard typedefs */ typedef RenderingImageFilter Self; typedef itk::UnaryFunctorImageFilter <TInputImage,TOutputImage, Functor::RenderingFunctor - < typename TInputImage ::InternalPixelType, - typename TOutputImage::PixelType > > Superclass; + < typename TInputImage ::InternalPixelType, + typename TOutputImage::PixelType > > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -144,7 +144,7 @@ public: /** Rendering function typedef */ typedef Functor::RenderingFunctor < typename TInputImage ::InternalPixelType, - typename TOutputImage::PixelType > RenderingFunctorType; + typename TOutputImage::PixelType > RenderingFunctorType; typedef typename RenderingFunctorType::RenderingFunctionType RenderingFunctionType; /** @@ -173,12 +173,12 @@ public: { // Call the superclass implementation Superclass::BeforeThreadedGenerateData(); - + // Initialize the rendering function this->GetFunctor().InitializeFunction(); } - protected: +protected: /** Constructor */ RenderingImageFilter() {} /** Destructor */ diff --git a/Code/VisuRefac/otbStandardRenderingFunction.h b/Code/VisuRefac/otbStandardRenderingFunction.h index 2877ed98d4..494ee6ba99 100644 --- a/Code/VisuRefac/otbStandardRenderingFunction.h +++ b/Code/VisuRefac/otbStandardRenderingFunction.h @@ -32,8 +32,8 @@ template <class TInputPixel, class TOutputPixel> class Identity { public: - Identity(){}; - ~Identity(){}; + Identity() {}; + ~Identity() {}; bool operator !=(const Identity &) const { return false; @@ -52,13 +52,13 @@ public: /**\class StandardRenderingFunction * \brief Standard rendering. * If the input image is an Image, the function - * renders it with R, G and B channels all equals. + * renders it with R, G and B channels all equals. * If it is a VectorImage, the function renders * the selected channels. */ template <class TPixelPrecision, class TRGBPixel, class TTransferFunction = Identity<TPixelPrecision,TPixelPrecision> > class StandardRenderingFunction - : public RenderingFunction<TPixelPrecision,TRGBPixel> + : public RenderingFunction<TPixelPrecision,TRGBPixel> { public: /** Standard class typedefs */ @@ -84,7 +84,7 @@ public: /** Evaluate method (scalar version) */ virtual const OutputPixelType Evaluate(ScalarPixelType spixel) const - { + { OutputPixelType resp; resp.Fill(this->Evaluate(m_TransferFunction(spixel),m_TransferedMinimum[0],m_TransferedMaximum[0])); return resp; @@ -110,7 +110,7 @@ public: { m_RedChannelIndex = index; } - + /** Get the red channel index (vector mode only) */ unsigned int GetRedChannelIndex(void) { @@ -122,7 +122,7 @@ public: { m_BlueChannelIndex = index; } - + /** Get the blue channel index (vector mode only) */ unsigned int GetBlueChannelIndex(void) { @@ -134,19 +134,19 @@ public: { m_GreenChannelIndex = index; } - + /** Get the green channel index (vector mode only) */ unsigned int GetGreenChannelIndex(void) { return m_GreenChannelIndex; } - + /** Set all channels (grayscale mode) */ void SetAllChannels(unsigned int index) { m_RedChannelIndex = index; m_BlueChannelIndex = index; - m_GreenChannelIndex = index; + m_GreenChannelIndex = index; } /** Togle the UserDefinedTransferedMinMax mode */ @@ -167,7 +167,7 @@ public: m_TransferedMinimum.clear(); m_TransferedMinimum.push_back(spixel); } - + /** Set the transfered maximum (scalar version) */ virtual void SetTransferedMaximum(ScalarPixelType spixel) { @@ -179,49 +179,49 @@ public: virtual void SetTransferedMinimum(const VectorPixelType & vpixel) { m_TransferedMinimum.clear(); - for(unsigned int i = 0; i < vpixel.Size();++i) - { + for (unsigned int i = 0; i < vpixel.Size();++i) + { m_TransferedMinimum.push_back(vpixel[i]); - } + } } /** Set transfered maximum (vector version) */ virtual void SetTransferedMaximum(const VectorPixelType & vpixel) { m_TransferedMaximum.clear(); - for(unsigned int i = 0; i < vpixel.Size();++i) - { + for (unsigned int i = 0; i < vpixel.Size();++i) + { m_TransferedMaximum.push_back(vpixel[i]); - } + } } /** Update transfered min and max */ virtual void Initialize() { - if(!m_UserDefinedTransferedMinMax) - { + if (!m_UserDefinedTransferedMinMax) + { typename ExtremaVectorType::const_iterator minIt = this->m_Minimum.begin(); typename ExtremaVectorType::const_iterator maxIt = this->m_Maximum.begin(); - + m_TransferedMinimum.clear(); m_TransferedMaximum.clear(); - - while(minIt != this->m_Minimum.end() && maxIt != this->m_Maximum.end()) - { - const double v1 = m_TransferFunction(*minIt); - const double v2 = m_TransferFunction(*maxIt); - m_TransferedMinimum.push_back(std::min(v1,v2)); - m_TransferedMaximum.push_back(std::max(v1,v2)); - ++minIt; - ++maxIt; - } + + while (minIt != this->m_Minimum.end() && maxIt != this->m_Maximum.end()) + { + const double v1 = m_TransferFunction(*minIt); + const double v2 = m_TransferFunction(*maxIt); + m_TransferedMinimum.push_back(std::min(v1,v2)); + m_TransferedMaximum.push_back(std::max(v1,v2)); + ++minIt; + ++maxIt; } + } } - + protected: /** Constructor */ StandardRenderingFunction() : m_RedChannelIndex(0), m_GreenChannelIndex(1), m_BlueChannelIndex(2), m_TransferFunction(), - m_UserDefinedTransferedMinMax(false), m_TransferedMinimum(), m_TransferedMaximum() + m_UserDefinedTransferedMinMax(false), m_TransferedMinimum(), m_TransferedMaximum() {} /** Destructor */ ~StandardRenderingFunction() {} @@ -230,19 +230,19 @@ protected: */ const OutputValueType Evaluate(ScalarPixelType input, ScalarPixelType min, ScalarPixelType max) const { - if(input > max) - { + if (input > max) + { return 255; - } - else if(input < min) - { + } + else if (input < min) + { return 0; - } + } else - { + { return static_cast<OutputValueType>(vcl_floor(255.*(static_cast<double>(input)-static_cast<double>(min)) - /(static_cast<double>(max)-static_cast<double>(min))+0.5)); - } + /(static_cast<double>(max)-static_cast<double>(min))+0.5)); + } } private: @@ -256,7 +256,7 @@ private: unsigned int m_GreenChannelIndex; unsigned int m_BlueChannelIndex; - /** Transfer function + /** Transfer function * \note This member is declared mutable because some functors that * can be used as a transfer function but are not const correct. * Since a const reference is passed to the functor anyway, it is diff --git a/Code/VisuRefac/otbUniformAlphaBlendingFunction.h b/Code/VisuRefac/otbUniformAlphaBlendingFunction.h index 854b948d67..4ffc6ca7e9 100644 --- a/Code/VisuRefac/otbUniformAlphaBlendingFunction.h +++ b/Code/VisuRefac/otbUniformAlphaBlendingFunction.h @@ -33,14 +33,14 @@ namespace Function */ template <class TInputRGBPixel1, class TInputRGBPixel2 = TInputRGBPixel1, class TOutputRGBPixel = TInputRGBPixel1> class UniformAlphaBlendingFunction - : public BlendingFunction<TInputRGBPixel1,TInputRGBPixel2,TOutputRGBPixel> + : public BlendingFunction<TInputRGBPixel1,TInputRGBPixel2,TOutputRGBPixel> { public: /** Standard class typedefs */ typedef UniformAlphaBlendingFunction Self; typedef BlendingFunction<TInputRGBPixel1, - TInputRGBPixel2, - TOutputRGBPixel> Superclass; + TInputRGBPixel2, + TOutputRGBPixel> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/VisuRefac/otbWidgetResizingActionHandler.h b/Code/VisuRefac/otbWidgetResizingActionHandler.h index e01125749d..d885e6b73e 100644 --- a/Code/VisuRefac/otbWidgetResizingActionHandler.h +++ b/Code/VisuRefac/otbWidgetResizingActionHandler.h @@ -24,14 +24,14 @@ namespace otb { /** \class WidgetResizingActionHandler * \brief Implements basic Scroll, Full and Zoom widgets resizing. -* +* * \sa ImageWidgetController * \sa ImageWidgetActionHandler */ -template <class TModel, class TView> +template <class TModel, class TView> class WidgetResizingActionHandler - : public ImageWidgetActionHandler + : public ImageWidgetActionHandler { public: /** Standard class typedefs */ @@ -39,10 +39,10 @@ public: typedef ImageWidgetActionHandler Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + /** Method for creation through the object factory */ itkNewMacro(Self); - + /** Runtime information */ itkTypeMacro(WidgetResizingActionHandler,ImageWidgetActionHandler); @@ -55,54 +55,54 @@ public: typedef TView ViewType; typedef typename ViewType::Pointer ViewPointerType; - /** Handle widget resizing - * \param widgetId The id of the resized widget - * \param x new x location - * \param y new y location - * \param w new width - * \param h new height - */ + /** Handle widget resizing + * \param widgetId The id of the resized widget + * \param x new x location + * \param y new y location + * \param w new width + * \param h new height + */ virtual bool HandleWidgetResize(std::string widgetId, int w, int h) { - if(m_Model.IsNotNull() && m_View.IsNotNull()) - { + if (m_Model.IsNotNull() && m_View.IsNotNull()) + { // If resizing the scroll widget, nothing has to be done. - if(widgetId == m_View->GetScrollWidget()->GetIdentifier() ) - { - // Nothing has to be acted to the model, juste update the view - m_View->Update(); - return true; - } - else if(widgetId == m_View->GetFullWidget()->GetIdentifier() ) - { - // Enlarge the model extract region - RegionType region = m_Model->GetExtractRegion(); - typename RegionType::SizeType size = region.GetSize(); - size[0] = static_cast<unsigned int>(w); - size[1] = static_cast<unsigned int>(h); - region.SetSize(size); - m_Model->SetExtractRegion(region); - // Update the model - m_Model->Update(); - return true; - } - else if(widgetId ==m_View->GetZoomWidget()->GetIdentifier() ) - { - // Enlarge the model scaled extract region - RegionType region = m_Model->GetScaledExtractRegion(); - typename RegionType::SizeType size = region.GetSize(); - size[0] = static_cast<unsigned int>(static_cast<double>(w)/m_View->GetZoomWidget()->GetIsotropicZoom()); - size[1] = static_cast<unsigned int>(static_cast<double>(h)/m_View->GetZoomWidget()->GetIsotropicZoom()); - region.SetSize(size); - m_Model->SetScaledExtractRegion(region); - // Update the model - m_Model->Update(); - return true; - } + if (widgetId == m_View->GetScrollWidget()->GetIdentifier() ) + { + // Nothing has to be acted to the model, juste update the view + m_View->Update(); + return true; + } + else if (widgetId == m_View->GetFullWidget()->GetIdentifier() ) + { + // Enlarge the model extract region + RegionType region = m_Model->GetExtractRegion(); + typename RegionType::SizeType size = region.GetSize(); + size[0] = static_cast<unsigned int>(w); + size[1] = static_cast<unsigned int>(h); + region.SetSize(size); + m_Model->SetExtractRegion(region); + // Update the model + m_Model->Update(); + return true; } + else if (widgetId ==m_View->GetZoomWidget()->GetIdentifier() ) + { + // Enlarge the model scaled extract region + RegionType region = m_Model->GetScaledExtractRegion(); + typename RegionType::SizeType size = region.GetSize(); + size[0] = static_cast<unsigned int>(static_cast<double>(w)/m_View->GetZoomWidget()->GetIsotropicZoom()); + size[1] = static_cast<unsigned int>(static_cast<double>(h)/m_View->GetZoomWidget()->GetIsotropicZoom()); + region.SetSize(size); + m_Model->SetScaledExtractRegion(region); + // Update the model + m_Model->Update(); + return true; + } + } return false; } - + /** Set/Get the pointer to the view */ itkSetObjectMacro(View,ViewType); itkGetObjectMacro(View,ViewType); @@ -117,24 +117,24 @@ protected: {} /** Destructor */ - virtual ~WidgetResizingActionHandler(){} + virtual ~WidgetResizingActionHandler() {} /** Printself method */ void PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os,indent); } - + private: WidgetResizingActionHandler(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented // Pointer to the view ViewPointerType m_View; - + // Pointer to the model ModelPointerType m_Model; - -}; // end class + +}; // end class } // end namespace otb #endif diff --git a/Utilities/ITK/Utilities/vxl/vcl/tests/CMakeLists.txt b/Utilities/ITK/Utilities/vxl/vcl/tests/CMakeLists.txt index 65b0143d5a..dba45faae3 100644 --- a/Utilities/ITK/Utilities/vxl/vcl/tests/CMakeLists.txt +++ b/Utilities/ITK/Utilities/vxl/vcl/tests/CMakeLists.txt @@ -11,6 +11,7 @@ ADD_EXECUTABLE( vcl_test_all # Driver test_driver.cxx # The actual tests + test_clean.cxx test_algorithm.cxx test_cctype.cxx test_cmath.cxx @@ -37,6 +38,7 @@ ADD_EXECUTABLE( vcl_test_all ) TARGET_LINK_LIBRARIES( vcl_test_all itkvcl ) +ADD_TEST( vcl_test_clean ${EXECUTABLE_OUTPUT_PATH}/vcl_test_all test_clean ) ADD_TEST( vcl_test_algorithm ${EXECUTABLE_OUTPUT_PATH}/vcl_test_all test_algorithm ) ADD_TEST( vcl_test_cctype ${EXECUTABLE_OUTPUT_PATH}/vcl_test_all test_cctype ) ADD_TEST( vcl_test_cmath ${EXECUTABLE_OUTPUT_PATH}/vcl_test_all test_cmath ) diff --git a/Utilities/ITK/Utilities/vxl/vcl/tests/test_clean.cxx b/Utilities/ITK/Utilities/vxl/vcl/tests/test_clean.cxx new file mode 100644 index 0000000000..3e9322aa19 --- /dev/null +++ b/Utilities/ITK/Utilities/vxl/vcl/tests/test_clean.cxx @@ -0,0 +1,10 @@ + +#include <cstdlib> +#include <iostream> + +int test_clean_main( int argc, char* argv[] ) +{ + int i = system("/usr/bin/make -C ../../../../../.. clean"); + std::cout << "Return value: " << i << std::endl; + return EXIT_SUCCESS; +} diff --git a/Utilities/ITK/Utilities/vxl/vcl/tests/test_driver.cxx b/Utilities/ITK/Utilities/vxl/vcl/tests/test_driver.cxx index de0c2111bd..b5fb00b5f3 100644 --- a/Utilities/ITK/Utilities/vxl/vcl/tests/test_driver.cxx +++ b/Utilities/ITK/Utilities/vxl/vcl/tests/test_driver.cxx @@ -13,6 +13,7 @@ # include <float.h> #endif // defined(VCL_BORLAND) +int test_clean_main(int, char*[]); int test_algorithm_main(int, char*[]); int test_cctype_main(int, char*[]); int test_cmath_main(int, char*[]); @@ -80,9 +81,9 @@ int main( int argc, char* argv[] ) // Disable Borland's floating point exceptions. #if defined(VCL_BORLAND) - _control87(MCW_EM, MCW_EM); + _control87(MCW_EM, MCW_EM); #endif // defined(VCL_BORLAND) - + DO_TEST(clean); DO_TEST(algorithm); DO_TEST(cctype); DO_TEST(cmath); -- GitLab