Orfeo Toolbox  4.0
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  for (unsigned int i = 0; i < m_NumberOfComponentsPerPixel; ++i)
162  {
163 
164  MultiToMonoChannelFilterPointer multiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
165  InterpolatorPointer interpolator = InterpolatorType::New();
166  FTMFilterPointer FTMFilter = FTMFilterType::New();
167 
168  multiToMonoChannelFilter->SetInput(m_LabelMapToSimulatedImageFilter->GetOutput());
169  multiToMonoChannelFilter->SetChannel(i + 1);
170  multiToMonoChannelFilter->SetExtractionRegion(
171  m_LabelMapToSimulatedImageFilter->GetOutput()->GetLargestPossibleRegion());
172 
173  //TODO comment changer interpolateur !
174  interpolator->SetInputImage(multiToMonoChannelFilter->GetOutput());
175  interpolator->SetRadius(m_Radius);
176  interpolator->Initialize();
177 
178  multiToMonoChannelFilter->UpdateOutputInformation();
179 
180  FTMFilter->SetInterpolator(interpolator);
181  // FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
182  FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
183  FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing());
184  FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin());
185  FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput());
186  FTMFilter->Update();
187 
188  m_ImageList->PushBack(FTMFilter->GetOutput());
189  }
190  m_ImageListToVectorImageFilter->SetInput(m_ImageList);
191 
192 }
193 
194 //In case of a true composite filter
195 // template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
196 // void
197 // ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSimulationStep2, TFTM, TOutputImage>
198 // ::GenerateData()
199 // {
200 //
201 // // m_Spatialisation->SetInput(m_InputVectorData);
202 // // m_Spatialisation->SetInitialLabel(1);
203 // // m_Spatialisation->SetBackgroundValue(0);
204 //
205 // m_LabelMapToSimulatedImageFilter->SetInput(m_Spatialisation->GetOutput());
206 // m_LabelMapToSimulatedImageFilter->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
207 // m_LabelMapToSimulatedImageFilter->SetSatRSRFilename(m_SatRSRFilename);
208 // m_LabelMapToSimulatedImageFilter->SetNumberOfThreads(1);
209 // m_LabelMapToSimulatedImageFilter->SetPathRoot(m_PathRoot);
210 // m_LabelMapToSimulatedImageFilter->SetMean(m_Mean);
211 // m_LabelMapToSimulatedImageFilter->SetVariance(m_Variance);
212 //
213 // m_LabelMapToLabelImageFilter->SetInput(m_Spatialisation->GetOutput());
214 // m_LabelMapToLabelImageFilter->GraftNthOutput(0, this->GetOutputLabelImage());
215 // m_LabelMapToLabelImageFilter->Update();
216 // this->GraftNthOutput(1, m_LabelMapToLabelImageFilter->GetOutput());
217 //
218 // // m_LabelMapToSimulatedImageFilter->GraftNthOutput(0, this->GetOutputReflectanceImage());
219 // // m_LabelMapToSimulatedImageFilter->Update();
220 // // this->GraftNthOutput(0, m_LabelMapToSimulatedImageFilter->GetOutput());
221 //
222 // for(unsigned int i = 0; i<m_NumberOfComponentsPerPixel; ++i)
223 // {
224 //
225 // MultiToMonoChannelFilterPointer multiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
226 // InterpolatorPointer interpolator = InterpolatorType::New();
227 // FTMFilterPointer FTMFilter = FTMFilterType::New();
228 //
229 // multiToMonoChannelFilter->SetInput(m_LabelMapToSimulatedImageFilter->GetOutput());
230 // multiToMonoChannelFilter->SetChannel(i+1);
231 // multiToMonoChannelFilter->SetExtractionRegion(m_LabelMapToSimulatedImageFilter->GetOutput()->GetLargestPossibleRegion());
232 //
233 //
234 // //TODO comment changer interpolateur !
235 // interpolator->SetInputImage(multiToMonoChannelFilter->GetOutput());
236 // interpolator->SetRadius(m_Radius);
237 // interpolator->Initialize();
238 //
239 // multiToMonoChannelFilter->UpdateOutputInformation();
240 //
241 // FTMFilter->SetInterpolator(interpolator);
242 // // FTMFilter->SetOutputSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
243 // FTMFilter->SetSize(multiToMonoChannelFilter->GetOutput()->GetLargestPossibleRegion().GetSize());
244 // FTMFilter->SetOutputSpacing(multiToMonoChannelFilter->GetOutput()->GetSpacing());
245 // FTMFilter->SetOutputOrigin(multiToMonoChannelFilter->GetOutput()->GetOrigin());
246 // FTMFilter->SetInput(multiToMonoChannelFilter->GetOutput());
247 // FTMFilter->Update();
248 //
249 // m_ImageList->PushBack(FTMFilter->GetOutput());
250 // }
251 // m_ImageListToVectorImageFilter->SetInput(m_ImageList);
252 //
253 // m_ImageListToVectorImageFilter->GraftNthOutput(0, this->GetOutputReflectanceImage());
254 // m_ImageListToVectorImageFilter->Update();
255 // this->GraftNthOutput(0, m_ImageListToVectorImageFilter->GetOutput());
256 //
257 // }
258 
259 
260 template <class TInputVectorData, class TSpatialisation, class TSimulationStep1, class TSimulationStep2, class TFTM, class TOutputImage>
261 void
263 ::PrintSelf(std::ostream& os, itk::Indent indent) const
264 {
265  Superclass::PrintSelf(os, indent);
266 
267 }
268 
269 } //end namespace otb
270 
271 #endif
272 

Generated at Sat Apr 19 2014 16:02:57 for Orfeo Toolbox with doxygen 1.8.3.1