diff --git a/include/dummy_filter.h b/include/dummy_filter.h new file mode 100644 index 0000000000000000000000000000000000000000..ea6dd8d21a24f0a956810557e584c58226811dcb --- /dev/null +++ b/include/dummy_filter.h @@ -0,0 +1,47 @@ +#ifndef __dummy_Filter_h +#define __dummy_Filter_h + +#include "itkImageToImageFilter.h" +#include "itkMacro.h" + + +template< class TImage> +class ITK_EXPORT DummyFilter:public itk::ImageToImageFilter< TImage, TImage > +{ + public: + /** Standard class typedefs. */ + typedef DummyFilter Self; + typedef itk::ImageToImageFilter< TImage, TImage > Superclass; + typedef itk::SmartPointer< Self > Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(DummyFilter, ImageToImageFilter); + + //void SetInputImage(const TImage* image); + + + protected: + DummyFilter(); + ~DummyFilter(){} + + typename TImage::ConstPointer GetInputImage(); + + /** Does the real work. */ + + virtual void BeforeThreadedGenerateData(); + void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; + + private: + DummyFilter(const Self &); //purposely not implemented + void operator=(const Self &); //purposely not implemented +}; + +#ifndef ITK_MANUAL_INSTANTIATION +#include "dummy_filter.txx" +#endif + + +#endif // __dummy_Filter_h diff --git a/include/dummy_filter.txx b/include/dummy_filter.txx new file mode 100644 index 0000000000000000000000000000000000000000..2ec1ced9e8c12bae20af87261b89399d0ce6af8c --- /dev/null +++ b/include/dummy_filter.txx @@ -0,0 +1,79 @@ +#ifndef __dummy_filter_txx +#define __dummy_filter_txx + +#include "dummy_filter.h" +#include <fstream> + + +#include "itkObjectFactory.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" +#include "otbVectorImage.h" + +/* +#include <shark/Data/Csv.h> +#include <shark/Data/Pgm.h> //for exporting the learned filters +#include <shark/Data/SparseData.h>//for reading in the images as sparseData/Libsvm format +#include <shark/Models/Autoencoder.h>//normal autoencoder model +#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights +#include <shark/Models/Normalizer.h> +#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> +*/ + +//using namespace shark; + +template< class TImage> +DummyFilter<TImage>::DummyFilter() +{ + this->SetNumberOfRequiredInputs(1); +} + + + +template< class TImage> +typename TImage::ConstPointer DummyFilter<TImage>::GetInputImage() +{ + return static_cast< const TImage * > + ( this->itk::ProcessObject::GetInput(0) ); +} + + + + + +template< class TImage> +void DummyFilter<TImage>::BeforeThreadedGenerateData() +{ +#ifdef _OPENMP +// OpenMP will take care of threading +this->SetNumberOfThreads(1); +#endif +} + + +/*template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateData()*/ +template< class TImage> +void DummyFilter<TImage>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) +{ + //Data_with_info info; + typename TImage::ConstPointer input = this->GetInput(); + typename TImage::Pointer output = this->GetOutput(); + + // Image to vector + const unsigned int img_bands = input->GetNumberOfComponentsPerPixel(); + + itk::ImageRegionConstIterator<TImage> inputIterator(input,outputRegionForThread); + itk::ImageRegionIterator<TImage> imageIteratorOut(output,outputRegionForThread); + + typename TImage::PixelType pixelValue; + while(!inputIterator.IsAtEnd()){ + imageIteratorOut.Set(inputIterator.Get()); + ++inputIterator; + ++imageIteratorOut; + } + +} + + +#endif