Newer
Older
Cédric Traizet
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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