diff --git a/Code/BasicFilters/otbCountImageFilter.h b/Code/BasicFilters/otbCountImageFilter.h deleted file mode 100644 index 7dececf6a8b15c847b22286a637216fc3a72bee7..0000000000000000000000000000000000000000 --- a/Code/BasicFilters/otbCountImageFilter.h +++ /dev/null @@ -1,127 +0,0 @@ -/*========================================================================= - -Program: ORFEO Toolbox -Language: C++ -Date: $Date$ -Version: $Revision$ - - -Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. -See OTBCopyright.txt for details. - -Copyright (c) CS Systemes d'information. All rights reserved. -See CSCopyright.txt for details. - -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. - -=========================================================================*/ -#ifndef __otbCountImageFilter_h -#define __otbCountImageFilter_h - - -#include "itkImageToImageFilter.h" -#include "itkProcessObject.h" -#include "otbCountImageFunction.h" -#include "itkNumericTraits.h" - - -/** \class CountImageFilter - * \brief This class extracts key points from an image through a pyramidal gaussian based decomposition - - * - */ - -namespace otb -{ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -class ITK_EXPORT CountImageFilter - : public itk::ImageToImageFilter<TInputImage, TOutputImage> -{ - -public: - - /** Standard class typedefs. */ - typedef CountImageFilter Self; - typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass ; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(CountImageFilter,itk::ImageToImageFilter); - - - /** Template parameters typedefs*/ - typedef TInputImage InputImageType; - typedef typename InputImageType::Pointer InputImagePointerType; - typedef typename InputImageType::IndexType IndexType; - - /** OutputImageType typedef support*/ - typedef typename Superclass::OutputImageType OutputImageType; - typedef typename OutputImageType::Pointer OutputImagePointerType; - typedef typename OutputImageType::RegionType OutputImageRegionType; - typedef typename OutputImageType::PixelType OutputPixelType; - - typedef typename itk::NumericTraits< OutputPixelType>::RealType OutputRealType; - - /** Detector typedef Support*/ - typedef TDetector DetectorType; - - /** Count Function typedef Support*/ - typedef TCount CountMethodType; - - /** CountImageFunction support*/ - typedef otb::CountImageFunction<InputImageType,DetectorType, - CountMethodType > CountImageFunctionType; - typedef typename CountImageFunctionType::Pointer CountImageFunctionTypePointer; - - /** Get/Set the radius of the neighborhood over which the - statistics are evaluated */ - itkSetMacro( NeighborhoodRadius, unsigned int ); - itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int ); - - - /**Set/Get Descriptor from the otbCountmageFunction*/ - virtual void SetDetector(DetectorType* detector); - virtual DetectorType* GetDetector(); - -protected: - - /** - * Constructor. - */ - CountImageFilter(); - /** - * Destructor. - */ - virtual ~CountImageFilter(); - /** - * Standard PrintSelf method. - */ - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; - /** - * Main computation method. - */ - virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); - -private: - - CountImageFilter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - CountImageFunctionTypePointer m_CountImageFunction; - - unsigned int m_NeighborhoodRadius; -}; -} -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbCountImageFilter.txx" -#endif - -#endif - - diff --git a/Code/BasicFilters/otbCountImageFilter.txx b/Code/BasicFilters/otbCountImageFilter.txx deleted file mode 100644 index 4f8338dc205ccf57481c964c640862721769d270..0000000000000000000000000000000000000000 --- a/Code/BasicFilters/otbCountImageFilter.txx +++ /dev/null @@ -1,128 +0,0 @@ -/*========================================================================= - -Program: ORFEO Toolbox -Language: C++ -Date: $Date$ -Version: $Revision$ - - -Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. -See OTBCopyright.txt for details. - -Copyright (c) CS systèmes d'information. All rights reserved. -See CSCopyright.txt for details. - -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. - -=========================================================================*/ - -#include "otbCountImageFilter.h" -#include "itkImageRegionIterator.h" - - -namespace otb -{ -/**--------------------------------------------------------- - * Constructor - ----------------------------------------------------------*/ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -CountImageFilter<TInputImage , TDetector, TCount, TOutputImage> -::CountImageFilter() -{ - this->SetNumberOfRequiredInputs( 1 ); - m_CountImageFunction = CountImageFunctionType::New(); - m_NeighborhoodRadius = 1; -} - - -/*--------------------------------------------------------- - * Destructor.c - ----------------------------------------------------------*/ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -CountImageFilter<TInputImage, TDetector, TCount, TOutputImage > -::~CountImageFilter() -{} - -/** - * threaded Generate Data - */ - -/** -* ThreadedGenerateData Performs the pixel-wise addition -*/ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -void -CountImageFilter<TInputImage, TDetector, TCount, TOutputImage > -::ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, int threadId ) -{ - typename Superclass::OutputImagePointer outputImage = this->GetOutput(); - InputImagePointerType ptr = const_cast<InputImageType *>(this->GetInput()); - - /** Update the radius for the CountImageFunction */ - m_CountImageFunction->SetInputImage(ptr); - m_CountImageFunction->SetNeighborhoodRadius(m_NeighborhoodRadius); - - - itk::ImageRegionIterator<InputImageType> - itInput(ptr, ptr->GetLargestPossibleRegion()); - - itk::ImageRegionIterator<OutputImageType> - itOutput(outputImage, outputImage->GetLargestPossibleRegion()); - - itInput.GoToBegin(); - itOutput.GoToBegin(); - - while (!itInput.IsAtEnd() && !itOutput.IsAtEnd()) - { - IndexType index = itInput.GetIndex(); - itOutput.Set(m_CountImageFunction->EvaluateAtIndex(index)); - - ++itInput; - ++itOutput; - } - - -} - - -/** - * Set Detector - */ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -void -CountImageFilter<TInputImage, TDetector, TCount, TOutputImage > -::SetDetector(DetectorType* detector) -{ - m_CountImageFunction->SetDetector(detector); -} - - -/** - * Get Detector - */ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -typename CountImageFilter< TInputImage , TDetector, TCount, TOutputImage > -::DetectorType * -CountImageFilter< TInputImage , TDetector, TCount, TOutputImage > -::GetDetector() -{ - return m_CountImageFunction->GetDetector(); -} - - - -/*---------------------------------------------------------------- - PrintSelf - -----------------------------------------------------------------*/ -template <class TInputImage , class TDetector, class TCount, class TOutputImage> -void -CountImageFilter< TInputImage , TDetector, TCount, TOutputImage > -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - os << indent << "Neighborhood Radius " << m_NeighborhoodRadius << std::endl; -} - -}/** end namesapce otb*/ diff --git a/Code/BasicFilters/otbKeyPointDensityImageFilter.h b/Code/BasicFilters/otbKeyPointDensityImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..445abdd0e9e16aa3c2d98dc1c3f04ebad34ca36c --- /dev/null +++ b/Code/BasicFilters/otbKeyPointDensityImageFilter.h @@ -0,0 +1,121 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + +Copyright (c) CS Systemes d'information. All rights reserved. +See CSCopyright.txt for details. + +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. + +=========================================================================*/ +#ifndef __otbKeyPointDensityImageFilter_h +#define __otbKeyPointDensityImageFilter_h + + +#include "itkImageToImageFilter.h" +#include "itkProcessObject.h" +#include "otbPointSetToDensityImageFilter.h" +#include "itkNumericTraits.h" + + +/** \class KeyPointDensityImageFilter + * \brief + + * + */ + +namespace otb +{ + template <class TInputImage , class TDetector, class TOutputImage> + class ITK_EXPORT KeyPointDensityImageFilter + : public itk::ImageToImageFilter<TInputImage, TOutputImage> + { + + public: + + /** Standard class typedefs. */ + typedef KeyPointDensityImageFilter Self; + typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass ; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(KeyPointDensityImageFilter,itk::ImageToImageFilter); + + + /** Template parameters typedefs*/ + typedef TInputImage InputImageType; + typedef typename InputImageType::Pointer InputImagePointerType; + + /** OutputImageType typedef support*/ + typedef TOutputImage OutputImageType; + typedef typename OutputImageType::Pointer OutputImagePointerType; + + /** Detector typedef Support*/ + typedef TDetector DetectorType; + typedef typename DetectorType::OutputPointSetType PointSetType; + typedef typename DetectorType::Pointer DetectorPointerType; + + /** PointSetToDensityImageFilter support*/ + typedef otb::PointSetToDensityImageFilter<PointSetType, OutputImageType> PointSetToDensityImageType; + typedef typename PointSetToDensityImageType::Pointer PointSetToDensityImagePointerType; + + /** Get/Set the radius of the neighborhood over which the + statistics are evaluated */ + itkSetMacro( NeighborhoodRadius, unsigned int ); + itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int ); + + + /**Set/Get Descriptor from the otbCountmageFunction*/ + virtual void SetDetector(DetectorType* detector); + virtual DetectorType* GetDetector(); + + protected: + + /** + * Constructor. + */ + KeyPointDensityImageFilter(); + /** + * Destructor. + */ + virtual ~KeyPointDensityImageFilter(); + /** + * Standard PrintSelf method. + */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + /** + * Main computation method. + */ + //virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); + virtual void GenerateData( ); + + private: + + KeyPointDensityImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + DetectorPointerType m_Detector; + PointSetToDensityImagePointerType m_PointSetToDensityImageFilter; + unsigned int m_NeighborhoodRadius; + }; +} +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbKeyPointDensityImageFilter.txx" +#endif + +#endif + + diff --git a/Code/BasicFilters/otbKeyPointDensityImageFilter.txx b/Code/BasicFilters/otbKeyPointDensityImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..8ceca6e8b3e00e8cdfe736eac57e9fdcc31515fd --- /dev/null +++ b/Code/BasicFilters/otbKeyPointDensityImageFilter.txx @@ -0,0 +1,121 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + +Copyright (c) CS systèmes d'information. All rights reserved. +See CSCopyright.txt for details. + +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. + +=========================================================================*/ + +#include "otbKeyPointDensityImageFilter.h" +#include "itkImageRegionIterator.h" + + +namespace otb +{ + /**--------------------------------------------------------- + * Constructor + ----------------------------------------------------------*/ + template <class TInputImage , class TDetector, class TOutputImage> + KeyPointDensityImageFilter<TInputImage , TDetector, TOutputImage> + ::KeyPointDensityImageFilter() + { + this->SetNumberOfRequiredInputs( 1 ); + m_NeighborhoodRadius = 1; + m_Detector = DetectorType::New(); + m_PointSetToDensityImageFilter = PointSetToDensityImageType::New(); + } + + + /*--------------------------------------------------------- + * Destructor.c + ----------------------------------------------------------*/ + template <class TInputImage , class TDetector, class TOutputImage> + KeyPointDensityImageFilter<TInputImage, TDetector, TOutputImage > + ::~KeyPointDensityImageFilter() + {} + + /** + * threaded Generate Data + */ + + /** + * ThreadedGenerateData Performs the pixel-wise addition + */ +template <class TInputImage , class TDetector, class TOutputImage> +void +KeyPointDensityImageFilter<TInputImage, TDetector, TOutputImage > +::GenerateData() +//::GenerateData( const OutputImageRegionType &outputRegionForThread, int threadId ) +{ + typename Superclass::OutputImagePointer outputImage = this->GetOutput(); + InputImagePointerType ptr = const_cast<InputImageType *>(this->GetInput()); + if(!ptr) + return ; + + /** Detector*/ + m_Detector->SetInput(ptr); + + /** Applying the pointsetTodensityImageFilter*/ + m_PointSetToDensityImageFilter->SetInput(m_Detector->GetOutput()); + m_PointSetToDensityImageFilter->SetRadius(m_NeighborhoodRadius); + m_PointSetToDensityImageFilter->SetSpacing(ptr->GetSpacing()); + m_PointSetToDensityImageFilter->SetSize(ptr->GetLargestPossibleRegion().GetSize()); + m_PointSetToDensityImageFilter->SetOrigin(ptr->GetOrigin()); + m_PointSetToDensityImageFilter->Update(); + + /** updating the output*/ + this->GraftOutput(m_PointSetToDensityImageFilter->GetOutput()); +} + + + /** + * Set Detector + */ + template <class TInputImage , class TDetector, class TOutputImage> + void + KeyPointDensityImageFilter<TInputImage, TDetector, TOutputImage > + ::SetDetector(DetectorType* detector) + { + m_Detector = detector; + } + + + /** + * Get Detector + */ + template <class TInputImage , class TDetector, class TOutputImage> + typename KeyPointDensityImageFilter< TInputImage , TDetector, TOutputImage > + ::DetectorType * + KeyPointDensityImageFilter< TInputImage , TDetector, TOutputImage > + ::GetDetector() + { + return m_Detector; + } + + + + /*---------------------------------------------------------------- + PrintSelf + -----------------------------------------------------------------*/ + template <class TInputImage , class TDetector, class TOutputImage> + void + KeyPointDensityImageFilter< TInputImage , TDetector, TOutputImage > + ::PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os, indent); + os << indent << "Neighborhood Radius " << m_NeighborhoodRadius << std::endl; + } + +}/** end namesapce otb*/ diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 3b7403846f5f98b17a29d94b9bbf74bf52498c1c..7bc20d4cdfa849df7d9b80e2d22cdc3177fe1efb 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1164,20 +1164,11 @@ ADD_TEST(bfTvImagePCAShapeModelEstimatorTest ${BASICFILTERS_TESTS11} ${TEMP}/imagePCAShapeModelEstimatorTest_eigen_vectors1.tif ${TEMP}/imagePCAShapeModelEstimatorTest_eigen_vectors2.tif ) -# -#ADD_TEST(bfTvCountImageFunction ${BASICFILTERS_TESTS11} -#--compare-ascii ${TOL} -# ${BASELINE_FILES}/bfTvCountImageFunctionOutputAscii.txt -# ${TEMP}/bfTvCountImageFunctionOutputAscii.txt -# otbCountImageFunctionTest -# ${INPUTDATA}/QB_Suburb.png -# ${TEMP}/bfTvCountImageFunctionOutputAscii.txt -# 5 2 -#) -# ------- otbCountImageFilter ---------------------------- -#ADD_TEST(bfTuCountImageFilterNew ${BASICFILTERS_TESTS11} -# otbCountImageFilterNew -# ) + +# ------- otbKeyPointDensityImageFilter ---------------------------- +ADD_TEST(bfTuKeyPointDensityImageFilterNew ${BASICFILTERS_TESTS11} + otbKeyPointDensityImageFilterNew + ) #ADD_TEST(bfTvCountImageFilterOutputImage ${BASICFILTERS_TESTS11} #--compare-image ${TOL} @@ -1359,8 +1350,7 @@ otbPointSetDensityFunctionNew.cxx otbPointSetDensityFunctionTest.cxx otbPointSetToDensityImageFilterNew.cxx otbPointSetToDensityImageFilterTest.cxx -#otbCountImageFunctionTest.cxx -#otbCountImageFilterNew.cxx +otbKeyPointDensityImageFilterNew.cxx #otbCountImageFilterTest.cxx otbImagePCAShapeModelEstimatorTest.cxx otbFunctionWithNeighborhoodToImageFilterNew.cxx diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx index 3336f0ff53113a0983e7d06880ea256c1da993e8..57ff26ff626d3dc768f07d8cf474b1117fcc3e0b 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx @@ -33,8 +33,7 @@ REGISTER_TEST(otbPointSetDensityFunctionNew); REGISTER_TEST(otbPointSetDensityFunctionTest); REGISTER_TEST(otbPointSetToDensityImageFilterNew); REGISTER_TEST(otbPointSetToDensityImageFilterTest); -//REGISTER_TEST(otbCountImageFunctionTest); -//REGISTER_TEST(otbCountImageFilterNew); +REGISTER_TEST(otbKeyPointDensityImageFilterNew); //REGISTER_TEST(otbCountImageFilterTest); REGISTER_TEST(otbImagePCAShapeModelEstimatorTest); REGISTER_TEST(otbFunctionWithNeighborhoodToImageFilterNew); diff --git a/Testing/Code/BasicFilters/otbCountImageFilterNew.cxx b/Testing/Code/BasicFilters/otbKeyPointDensityImageFilterNew.cxx similarity index 56% rename from Testing/Code/BasicFilters/otbCountImageFilterNew.cxx rename to Testing/Code/BasicFilters/otbKeyPointDensityImageFilterNew.cxx index 7cb4c01feaf0e8cf773bce135de24556fc30ab13..243f8c332c05ea1e14f4d263af294d4a022b56aa 100644 --- a/Testing/Code/BasicFilters/otbCountImageFilterNew.cxx +++ b/Testing/Code/BasicFilters/otbKeyPointDensityImageFilterNew.cxx @@ -18,29 +18,25 @@ PURPOSE. See the above copyright notices for more information. #include <stdio.h> -#include "otbCountImageFilter.h" -#include "otbSiftFastImageFilter.h" -#include "otbSimplePointCountStrategy.h" +#include "otbKeyPointDensityImageFilter.h" +#include "otbImageToSIFTKeyPointSetFilter.h" #include "itkPointSet.h" #include "itkVariableLengthVector.h" #include "otbImage.h" -int otbCountImageFilterNew(int, char* [] ) +int otbKeyPointDensityImageFilterNew(int, char* [] ) { const unsigned int Dimension = 2; typedef float PixelType; - typedef otb::Image< PixelType, Dimension > ImageType; - typedef ImageType::IndexType IndexType; - typedef itk::VariableLengthVector<PixelType> RealVectorType; - typedef itk::PointSet<RealVectorType,Dimension> PointSetType; - typedef otb::SiftFastImageFilter<ImageType,PointSetType> DetectorType; + typedef otb::Image< PixelType, Dimension > ImageType; + typedef ImageType::IndexType IndexType; + typedef itk::VariableLengthVector<PixelType> RealVectorType; + typedef itk::PointSet<RealVectorType,Dimension> PointSetType; + typedef otb::ImageToSIFTKeyPointSetFilter<ImageType,PointSetType> DetectorType; - typedef otb::Count<PointSetType,unsigned int ,IndexType> CounterType; - - typedef otb::CountImageFilter< ImageType,DetectorType, - CounterType,ImageType> FilterType; + typedef otb::KeyPointDensityImageFilter< ImageType,DetectorType, ImageType> FilterType; /**Instancitation of an object*/ FilterType::Pointer filter = FilterType::New(); diff --git a/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx b/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx index 80c7e5623ce51c0f2cdb032a826589ccf779c3d4..294b7a49f6b28cda8390d16c19dc0238757372bd 100644 --- a/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx +++ b/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx @@ -33,9 +33,8 @@ int otbPointSetDensityFunctionNew(int, char* [] ) typedef itk::PointSet<RealVectorType,Dimension> PointSetType; typedef otb::PointSetDensityFunction <PointSetType,PixelType> FunctionType; - /**Instancitation of an object*/ - FunctionType filter(); - //FunctionType::Pointer filter = FunctionType::New(); + /**Instancitation of a Smart Pointer*/ + FunctionType::Pointer filter = FunctionType::New(); return EXIT_SUCCESS; } diff --git a/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx b/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx index dd6f7d9c91b5b599b521c177d2226f3d0fefa7ef..e8537b16ee738412de09d6cf414749a9d262b19b 100644 --- a/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx +++ b/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx @@ -37,7 +37,7 @@ int otbPointSetDensityFunctionTest(int argc, char* argv[] ) typedef otb::PointSetDensityFunction <PointSetType,PixelType> FunctionType; - /**Instancitation of an object*/ + /**Instancitation ofa Smart Pointer*/ PointSetType::Pointer pointSet = PointSetType::New(); FunctionType::Pointer filter = FunctionType::New(); std::ofstream outfile(outfname);