Skip to content
Snippets Groups Projects
Commit 8426dd2a authored by Cédric Traizet's avatar Cédric Traizet
Browse files

autoencoder dim reduc added to the dim reduc app, dummy filter added (to delete later)

parent 3c3eddd1
No related branches found
No related tags found
No related merge requests found
#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
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment