Orfeo Toolbox  4.2
otbImageSimulationMethod.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbImageSimulationMethod_txx
19 #define __otbImageSimulationMethod_txx
20 
22 
23 namespace otb
24 {
25 
26 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
29 {
30  //instanciation
31  m_Spatialisation = SpatialisationType::New();
32  m_LabelMapToSimulatedImageFilter = LabelMapToSimulatedImageFilterType::New();
33  m_LabelMapToLabelImageFilter = LabelMapToLabelImageFilterType::New();
34 
35  // this->SetNumberOfRequiredOutputs(2);
36  // this->SetNthOutput(0, OutputImageType::New());
37  // this->SetNthOutput(1, OutputLabelImageType::New());
38 
39  //TODO a changer mais pour le moment obligatoire car ProlateInterpolateImageFunction
40  // ne fonctionne qu'avec des images mono canal.
41  // m_FTMFilter = FTMFilterType::New();
42  // m_Interpolator = InterpolatorType::New();
43  // m_MultiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
44  m_ImageList = ImageListType::New();
45  m_ImageListToVectorImageFilter = ImageListToVectorImageFilterType::New();
46 
47  //default value
48  m_NumberOfComponentsPerPixel = 3;
49  m_Radius = 3;
50  m_SatRSRFilename = "";
51  m_PathRoot = "";
52  m_Mean = 0.0;
53  m_Variance = 1e-8;
54 }
55 
56 //The 3 commented methods are needed for a true composite filters.
57 
58 // template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
59 // void
60 // ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
61 // ::SetInput(const InputVectorDataType* object)
62 // {
63 // this->itk::ProcessObject::SetNthInput(0, const_cast<InputVectorDataType *>(object));
64 // }
65 //
66 // template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
67 // typename ImageSimulationMethod<TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>::InputVectorDataType *
68 // ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
69 // ::GetInput()
70 // {
71 // return static_cast<InputVectorDataType *>(this->itk::ProcessObject::GetInput(0));
72 // }
73 
75 // template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
76 // typename ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>::OutputImageType *
77 // ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
78 // ::GetOutputReflectanceImage()
79 // {
80 // if(this->GetNumberOfOutputs() < 2)
81 // {
82 // //exit
83 // return 0;
84 // }
85 // return static_cast<OutputImageType *>(this->itk::ProcessObject::GetOutput(0));
86 // }
87 //
88 // /** Get output label image */
89 // template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
90 // typename ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>::OutputLabelImageType *
91 // ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
92 // ::GetOutputLabelImage()
93 // {
94 // if(this->GetNumberOfOutputs() < 2)
95 // {
96 // //exit
97 // return 0;
98 // }
99 // return static_cast<OutputLabelImageType *>(this->itk::ProcessObject::GetOutput(1));
100 // }
101 
103 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
107 {
108  return m_ImageListToVectorImageFilter->GetOutput();
109 }
110 
112 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
116 {
117  return m_LabelMapToLabelImageFilter->GetOutput();
118 }
119 
120 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
121 void
124 {
125  Superclass::GenerateOutputInformation();
126 
127  OutputImageType * outputReflImage = this->GetOutputReflectanceImage();
128 
129 // m_Spatialisation->SetInput(m_InputVectorData);
130  m_Spatialisation->UpdateOutputInformation();
131 
132  outputReflImage->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
133  outputReflImage->SetLargestPossibleRegion(m_Spatialisation->GetOutput()->GetLargestPossibleRegion());
134  outputReflImage->SetOrigin(m_Spatialisation->GetOutput()->GetOrigin());
135 
136  OutputLabelImageType * outputLabelImage = this->GetOutputLabelImage();
137  outputLabelImage->SetLargestPossibleRegion(m_Spatialisation->GetOutput()->GetLargestPossibleRegion());
138  outputLabelImage->SetOrigin(m_Spatialisation->GetOutput()->GetOrigin());
139 }
140 
141 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
142 void
145 {
146 
147  // m_Spatialisation->SetInput(m_InputVectorData);
148  // m_Spatialisation->SetInitialLabel(1);
149  // m_Spatialisation->SetBackgroundValue(0);
150 
151  m_LabelMapToSimulatedImageFilter->SetInput(m_Spatialisation->GetOutput());
152  m_LabelMapToSimulatedImageFilter->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
153  m_LabelMapToSimulatedImageFilter->SetSatRSRFilename(m_SatRSRFilename);
154  m_LabelMapToSimulatedImageFilter->SetNumberOfThreads(1);
155  m_LabelMapToSimulatedImageFilter->SetPathRoot(m_PathRoot);
156  m_LabelMapToSimulatedImageFilter->SetMean(m_Mean);
157  m_LabelMapToSimulatedImageFilter->SetVariance(m_Variance);
158 
159  m_LabelMapToLabelImageFilter->SetInput(m_Spatialisation->GetOutput());
160 
161  m_LabelMapToSimulatedImageFilter->UpdateOutputInformation();
162 
163  for (unsigned int i = 0; i < m_NumberOfComponentsPerPixel; ++i)
164  {
165 
166  MultiToMonoChannelFilterPointer multiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
167  InterpolatorPointer interpolator = InterpolatorType::New();
168  FTMFilterPointer FTMFilter = FTMFilterType::New();
169 
170  multiToMonoChannelFilter->SetInput(m_LabelMapToSimulatedImageFilter->GetOutput());
171  multiToMonoChannelFilter->SetChannel(i + 1);
172  multiToMonoChannelFilter->SetExtractionRegion(
173  m_LabelMapToSimulatedImageFilter->GetOutput()->GetLargestPossibleRegion());
174 
175  //TODO comment changer interpolateur !
176  interpolator->SetInputImage(multiToMonoChannelFilter->GetOutput());
177  interpolator->SetRadius(m_Radius);
178  interpolator->Initialize();
179 
180  multiToMonoChannelFilter->UpdateOutputInformation();
181 
182  FTMFilter->SetInterpolator(interpolator);
183  // FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
184  FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
185  FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing());
186  FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin());
187  FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput());
188  FTMFilter->Update();
189 
190  m_ImageList->PushBack(FTMFilter->GetOutput());
191  }
192  m_ImageListToVectorImageFilter->SetInput(m_ImageList);
193 
194 }
195 
196 //In case of a true composite filter
197 // template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
198 // void
199 // ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
200 // ::GenerateData()
201 // {
202 //
203 // // m_Spatialisation->SetInput(m_InputVectorData);
204 // // m_Spatialisation->SetInitialLabel(1);
205 // // m_Spatialisation->SetBackgroundValue(0);
206 //
207 // m_LabelMapToSimulatedImageFilter->SetInput(m_Spatialisation->GetOutput());
208 // m_LabelMapToSimulatedImageFilter->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
209 // m_LabelMapToSimulatedImageFilter->SetSatRSRFilename(m_SatRSRFilename);
210 // m_LabelMapToSimulatedImageFilter->SetNumberOfThreads(1);
211 // m_LabelMapToSimulatedImageFilter->SetPathRoot(m_PathRoot);
212 // m_LabelMapToSimulatedImageFilter->SetMean(m_Mean);
213 // m_LabelMapToSimulatedImageFilter->SetVariance(m_Variance);
214 //
215 // m_LabelMapToLabelImageFilter->SetInput(m_Spatialisation->GetOutput());
216 // m_LabelMapToLabelImageFilter->GraftNthOutput(0, this->GetOutputLabelImage());
217 // m_LabelMapToLabelImageFilter->Update();
218 // this->GraftNthOutput(1, m_LabelMapToLabelImageFilter->GetOutput());
219 //
220 // // m_LabelMapToSimulatedImageFilter->GraftNthOutput(0, this->GetOutputReflectanceImage());
221 // // m_LabelMapToSimulatedImageFilter->Update();
222 // // this->GraftNthOutput(0, m_LabelMapToSimulatedImageFilter->GetOutput());
223 //
224 // for(unsigned int i = 0; i<m_NumberOfComponentsPerPixel; ++i)
225 // {
226 //
227 // MultiToMonoChannelFilterPointer multiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
228 // InterpolatorPointer interpolator = InterpolatorType::New();
229 // FTMFilterPointer FTMFilter = FTMFilterType::New();
230 //
231 // multiToMonoChannelFilter->SetInput(m_LabelMapToSimulatedImageFilter->GetOutput());
232 // multiToMonoChannelFilter->SetChannel(i+1);
233 // multiToMonoChannelFilter->SetExtractionRegion(m_LabelMapToSimulatedImageFilter->GetOutput()->GetLargestPossibleRegion());
234 //
235 //
236 // //TODO comment changer interpolateur !
237 // interpolator->SetInputImage(multiToMonoChannelFilter->GetOutput());
238 // interpolator->SetRadius(m_Radius);
239 // interpolator->Initialize();
240 //
241 // multiToMonoChannelFilter->UpdateOutputInformation();
242 //
243 // FTMFilter->SetInterpolator(interpolator);
244 // // FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
245 // FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
246 // FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing());
247 // FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin());
248 // FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput());
249 // FTMFilter->Update();
250 //
251 // m_ImageList->PushBack(FTMFilter->GetOutput());
252 // }
253 // m_ImageListToVectorImageFilter->SetInput(m_ImageList);
254 //
255 // m_ImageListToVectorImageFilter->GraftNthOutput(0, this->GetOutputReflectanceImage());
256 // m_ImageListToVectorImageFilter->Update();
257 // this->GraftNthOutput(0, m_ImageListToVectorImageFilter->GetOutput());
258 //
259 // }
260 
261 
262 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
263 void
265 ::PrintSelf(std::ostream& os, itk::Indent indent) const
266 {
267  Superclass::PrintSelf(os, indent);
268 
269 }
270 
271 } //end namespace otb
272 
273 #endif
274 

Generated at Sat Jul 26 2014 16:05:30 for Orfeo Toolbox with doxygen 1.8.3.1