diff --git a/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx b/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx index 1697e13bde6670ef50672d2c960766ab83f2306b..7d78276c47c3050368e09f2d04832780ebf09025 100644 --- a/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx @@ -79,7 +79,7 @@ public: typedef itk::BinaryThresholdImageFilter<LabelImageType, LabelImageType> ThresholdFilterType; - template<class TInput, class TOutput> + template <class TInput, class TOutput> struct EncoderFunctorType { StatsFilterType::LabelPopulationMapType* m_CountMap; @@ -93,17 +93,17 @@ public: static constexpr size_t m_NbStatsPerBand{4}; static constexpr size_t m_NbGlobalStats{1}; - size_t OutputSize(const std::array<size_t,1> & ) const + size_t OutputSize(const std::array<size_t, 1>&) const { return m_NbInputComponents*m_NbStatsPerBand+m_NbGlobalStats; } size_t OutputSize() const { - return m_NbInputComponents*m_NbStatsPerBand+m_NbGlobalStats; + return m_NbInputComponents * m_NbStatsPerBand + m_NbGlobalStats; } - TOutput operator()(TInput const &pix) + TOutput operator()(TInput const& pix) { TOutput outPix(OutputSize()); outPix.Fill(m_OutBvValue); @@ -135,11 +135,8 @@ public: else return false; } }; - typedef otb::FunctorImageFilter<EncoderFunctorType< - LabelValueType, - FloatVectorImageType::PixelType - >> EncoderFilterType; - + typedef otb::FunctorImageFilter<EncoderFunctorType<LabelValueType, FloatVectorImageType::PixelType>> EncoderFilterType; + /** Standard macro */ itkNewMacro(Self); itkTypeMacro(ZonalStatistics, Application); @@ -414,19 +411,18 @@ public: m_EncoderFilter->SetInput(m_RasterizeFilter->GetOutput()); } - m_EncoderFilter->GetModifiableFunctor().m_CountMap = &m_CountMap; - m_EncoderFilter->GetModifiableFunctor().m_MeanMap = &m_MeanMap; - m_EncoderFilter->GetModifiableFunctor().m_StdMap = &m_StdMap; - m_EncoderFilter->GetModifiableFunctor().m_MinMap = &m_MinMap; - m_EncoderFilter->GetModifiableFunctor().m_MaxMap = &m_MaxMap; - m_EncoderFilter->GetModifiableFunctor().m_NbInputComponents = m_InputImage->GetNumberOfComponentsPerPixel(); - m_EncoderFilter->GetModifiableFunctor().m_InNoData = m_IntNoData; - m_EncoderFilter->GetModifiableFunctor().m_OutBvValue = m_OutBvValue; - - otbAppLogINFO("Output raster image will have " << - (m_EncoderFilter->GetFunctor()).OutputSize() << " bands\n"); - AddProcess(m_EncoderFilter, "Encode output raster image"); - SetParameterOutputImage("out.raster.filename", m_EncoderFilter->GetOutput()); + m_EncoderFilter->GetModifiableFunctor().m_CountMap = &m_CountMap; + m_EncoderFilter->GetModifiableFunctor().m_MeanMap = &m_MeanMap; + m_EncoderFilter->GetModifiableFunctor().m_StdMap = &m_StdMap; + m_EncoderFilter->GetModifiableFunctor().m_MinMap = &m_MinMap; + m_EncoderFilter->GetModifiableFunctor().m_MaxMap = &m_MaxMap; + m_EncoderFilter->GetModifiableFunctor().m_NbInputComponents = m_InputImage->GetNumberOfComponentsPerPixel(); + m_EncoderFilter->GetModifiableFunctor().m_InNoData = m_IntNoData; + m_EncoderFilter->GetModifiableFunctor().m_OutBvValue = m_OutBvValue; + + otbAppLogINFO("Output raster image will have " << (m_EncoderFilter->GetFunctor()).OutputSize() << " bands\n"); + AddProcess(m_EncoderFilter, "Encode output raster image"); + SetParameterOutputImage("out.raster.filename", m_EncoderFilter->GetOutput()); } void WriteXMLStatsFile() diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index 4a1bc5880b271d8ef7b0af3e8b3f69cd7a79de05..bbb8f2757b801c60d4254f6c6662c02e0ca82120 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -46,25 +46,23 @@ namespace Wrapper namespace Functor { -template<class TInput, class TOutput> +template <class TInput, class TOutput> class LuminanceOperator { public: LuminanceOperator() = default; - - size_t OutputSize(const std::array<size_t,1> &) const + + size_t OutputSize(const std::array<size_t, 1>&) const { return 1; } virtual ~LuminanceOperator() = default; - TOutput operator() ( TInput input ) - { - TOutput out(1); - out[0] = m_LumCoef[0] * input[m_Rgb[0]] + - m_LumCoef[1] * input[m_Rgb[1]] + - m_LumCoef[2] * input[m_Rgb[2]] ; - return out; + TOutput operator()(TInput input) + { + TOutput out(1); + out[0] = m_LumCoef[0] * input[m_Rgb[0]] + m_LumCoef[1] * input[m_Rgb[1]] + m_LumCoef[2] * input[m_Rgb[2]]; + return out; } // end operator () @@ -86,7 +84,7 @@ private: std::vector<float> m_LumCoef; }; // end of functor class LuminanceOperator -} // namespace functor +} // namespace functor class ContrastEnhancement : public Application { @@ -127,9 +125,7 @@ public: typedef otb::StreamingStatisticsImageFilter < FloatImageType > StatsFilterType; - typedef otb::FunctorImageFilter < Functor::LuminanceOperator - <FloatVectorImageType::PixelType, FloatVectorImageType::PixelType> > - LuminanceFunctorType; + typedef otb::FunctorImageFilter<Functor::LuminanceOperator<FloatVectorImageType::PixelType, FloatVectorImageType::PixelType>> LuminanceFunctorType; typedef itk::StreamingImageFilter < LutType , LutType > StreamingImageFilterType; @@ -705,8 +701,8 @@ private: lumCoef[i] /= sum; } m_LuminanceFunctor = LuminanceFunctorType::New() ; - m_LuminanceFunctor->GetModifiableFunctor().SetRgb( rgb ); - m_LuminanceFunctor->GetModifiableFunctor().SetLumCoef( lumCoef ); + m_LuminanceFunctor->GetModifiableFunctor().SetRgb(rgb); + m_LuminanceFunctor->GetModifiableFunctor().SetLumCoef(lumCoef); m_LuminanceFunctor->SetInput( inImage ); m_LuminanceFunctor->UpdateOutputInformation(); } diff --git a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx index b34512b1cc5ece6abd394e5dfb250308807deff5..e2078b324c452888e803dbb950ad7a3fe6f7dac6 100644 --- a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx +++ b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx @@ -92,8 +92,8 @@ public: { m_OutputSize = nb; } - - size_t OutputSize(const std::array<size_t,1> & ) const + + size_t OutputSize(const std::array<size_t, 1>&) const { return m_OutputSize; } @@ -224,9 +224,7 @@ public: StreamingStatisticsMapFromLabelImageFilterType; // Inverse mapper for color->label operation - typedef otb::FunctorImageFilter - <Functor::VectorMapping - <RGBPixelType, LabelVectorType> > ColorToLabelFilterType; + typedef otb::FunctorImageFilter<Functor::VectorMapping<RGBPixelType, LabelVectorType>> ColorToLabelFilterType; // Streaming the input image for color->label operation typedef RGBImageType::RegionType RegionType; diff --git a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx index 8f39edc15f6d2414cbc5659dcbbbe75df4106053..dcc25d7101c02f9a879009032c1640d2a03f8c11 100644 --- a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx @@ -43,11 +43,11 @@ public: typedef std::vector<TOutput> ColorListType; - size_t OutputSize(const std::array<size_t,1> &) const + size_t OutputSize(const std::array<size_t, 1>&) const { return 3; } - + void AddColor(const TOutput& color) { m_ScoreColors.push_back(color); @@ -124,9 +124,7 @@ public: typedef otb::HooverInstanceFilter<LabelMapType> InstanceFilterType; typedef otb::LabelMapToAttributeImageFilter <LabelMapType, FloatVectorImageType> AttributeImageFilterType; - typedef otb::FunctorImageFilter - <Functor::HooverColorMapping - <FloatPixelType, Int16PixelType> > HooverColorFilterType; + typedef otb::FunctorImageFilter<Functor::HooverColorMapping<FloatPixelType, Int16PixelType>> HooverColorFilterType; private: void DoInit() override diff --git a/Modules/Core/Functor/include/otbDotProductImageFilter.h b/Modules/Core/Functor/include/otbDotProductImageFilter.h index 471787a8fd0280510f22c00f10056ab60ee36155..57af72b6e9f28a52d38d522f131c2e7529f09899 100644 --- a/Modules/Core/Functor/include/otbDotProductImageFilter.h +++ b/Modules/Core/Functor/include/otbDotProductImageFilter.h @@ -27,7 +27,8 @@ namespace otb { -namespace Functor { +namespace Functor +{ /** \class DotProductFunctor * @@ -35,14 +36,14 @@ namespace Functor { * * \ingroup OTBCommon */ -template<class TInput, class TOutput> +template <class TInput, class TOutput> class DotProductFunctor { public: - typedef TInput InputType; - typedef TOutput OutputType; + typedef TInput InputType; + typedef TOutput OutputType; - DotProductFunctor() = default; + DotProductFunctor() = default; virtual ~DotProductFunctor() = default; const InputType& GetVector() @@ -55,14 +56,14 @@ public: m_Vector = m; } - OutputType operator ()(const InputType& in) + OutputType operator()(const InputType& in) { assert(in.Size() == m.Size()); OutputType result = 0; - for(unsigned int i = 0; i < in.Size(); ++i) - { + for (unsigned int i = 0; i < in.Size(); ++i) + { result += in[i] * m_Vector[i]; - } + } return result; } @@ -79,15 +80,14 @@ private: * with respect to the specified vector * * \sa otb::Functor::DotProductFunctor - * + * * \ingroup Streamed * \ingroup Threaded * * \ingroup OTBFunctor */ template <typename TInputImage, typename TOutputImage> -using DotProductImageFilter = FunctorImageFilter< - Functor::DotProductFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType> >; +using DotProductImageFilter = FunctorImageFilter<Functor::DotProductFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>; } // namespace otb #endif diff --git a/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h b/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h index 8eeaf539b2858f0add4837138b404511b29bfe84..8734cbfc6ac8c67780a8c20e2d1383d3c5da0d24 100644 --- a/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h +++ b/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h @@ -48,13 +48,13 @@ public: ProjectiveProjectionFunctor() : m_OutputSize(0) {} virtual ~ProjectiveProjectionFunctor() {} - size_t OutputSize(const std::array<size_t,1> & nbBands) const; + size_t OutputSize(const std::array<size_t, 1>& nbBands) const; const InputType& GetProjectionDirection(); void SetProjectionDirection(const InputType& p); - OutputType operator ()(const InputType& in); + OutputType operator()(const InputType& in); private: unsigned int m_OutputSize; @@ -72,9 +72,8 @@ private: * \ingroup OTBProjection */ template <typename TInputImage, typename TOutputImage, typename TPrecision> -using ProjectiveProjectionImageFilter = FunctorImageFilter< - Functor::ProjectiveProjectionFunctor<typename TInputImage::PixelType, - typename TOutputImage::PixelType, TPrecision> >; +using ProjectiveProjectionImageFilter = + FunctorImageFilter<Functor::ProjectiveProjectionFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision>>; } // end namespace otb diff --git a/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h index 3306472785a8859fdd18a2626863d22e730ac816..9ab74bfde39ce562daafa25af5ba81be74a0111c 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h @@ -36,7 +36,7 @@ namespace Functor { * \brief Perform fully constrained least squares on a pixel * * \sa ISRAUnmixingImageFilter - * + * * \ingroup OTBUnmixing */ template<class TInput, class TOutput, class TPrecision> @@ -53,9 +53,9 @@ public: typedef vnl_matrix<PrecisionType> MatrixType; ISRAUnmixingFunctor(); - virtual ~ISRAUnmixingFunctor() =default; + virtual ~ISRAUnmixingFunctor() = default; - size_t OutputSize(const std::array<size_t,1> & nbBands) const; + size_t OutputSize(const std::array<size_t, 1>& nbBands) const; void SetEndmembersMatrix(const MatrixType& U); const MatrixType& GetEndmembersMatrix(void) const; @@ -116,9 +116,7 @@ private: * \ingroup OTBUnmixing */ template <typename TInputImage, typename TOutputImage, typename TPrecision> -using ISRAUnmixingImageFilter = FunctorImageFilter< - Functor::ISRAUnmixingFunctor<typename TInputImage::PixelType, - typename TOutputImage::PixelType, TPrecision> >; +using ISRAUnmixingImageFilter = FunctorImageFilter<Functor::ISRAUnmixingFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision>>; } // end namespace otb diff --git a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h index 28afc9d914592542f5955712ed09b6aeb64b29d9..aa3ef08ce40742422f2a3db3e12875be8ad46fe1 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h @@ -56,7 +56,7 @@ public: NCLSUnmixingFunctor(); virtual ~NCLSUnmixingFunctor() = default; - size_t OutputSize(const std::array<size_t,1> & nbBands) const; + size_t OutputSize(const std::array<size_t, 1>& nbBands) const; void SetEndmembersMatrix(const MatrixType& U); const MatrixType& GetEndmembersMatrix(void) const; @@ -119,9 +119,7 @@ private: * \ingroup OTBUnmixing */ template <typename TInputImage, typename TOutputImage, typename TPrecision> -using NCLSUnmixingImageFilter = FunctorImageFilter< - Functor::NCLSUnmixingFunctor<typename TInputImage::PixelType, - typename TOutputImage::PixelType, TPrecision> >; +using NCLSUnmixingImageFilter = FunctorImageFilter<Functor::NCLSUnmixingFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision>>; } // end namespace otb diff --git a/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h index 82d541808c4745a271ebb3f78e0b1c28cb242019..ae57d18a5b2df21e48401d0c6a33d7b0c530f219 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h @@ -50,14 +50,14 @@ public: typedef vnl_vector<PrecisionType> VectorType; typedef vnl_matrix<PrecisionType> MatrixType; - UnConstrainedLeastSquareFunctor() : m_OutputSize(0) {}; + UnConstrainedLeastSquareFunctor() : m_OutputSize(0){}; virtual ~UnConstrainedLeastSquareFunctor() = default; - size_t OutputSize(const std::array<size_t,1> & nbBands) const; + size_t OutputSize(const std::array<size_t, 1>& nbBands) const; void SetMatrix(const MatrixType& m); - OutputType operator ()(const InputType& in) const; + OutputType operator()(const InputType& in) const; private: @@ -92,9 +92,8 @@ private: * \ingroup OTBUnmixing */ template <typename TInputImage, typename TOutputImage, typename TPrecision> -using UnConstrainedLeastSquareImageFilter = FunctorImageFilter< - Functor::UnConstrainedLeastSquareFunctor<typename TInputImage::PixelType, - typename TOutputImage::PixelType, TPrecision> >; +using UnConstrainedLeastSquareImageFilter = + FunctorImageFilter<Functor::UnConstrainedLeastSquareFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision>>; } // end namespace otb