Orfeo Toolbox  4.2
otbLikelihoodPathListFilter.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 __otbLikelihoodPathListFilter_txx
19 #define __otbLikelihoodPathListFilter_txx
20 
23 #include "itkMetaDataObject.h"
24 #include "otbMacro.h"
25 
26 namespace otb
27 {
31 template <class TPath, class TImage>
34 {
35  m_Key = "Value";
36  this->SetNumberOfRequiredInputs(2);
37  this->SetNumberOfRequiredInputs(2);
38 }
39 template <class TPath, class TImage>
40 void
42 ::SetInputImage(const ImageType * image)
43 {
44  this->itk::ProcessObject::SetNthInput(1, const_cast<ImageType *>(image));
45 }
46 template <class TPath, class TImage>
48 ::ImageType *
51 {
52  if (this->GetNumberOfInputs() < 1)
53  {
54  return 0;
55  }
56  return static_cast<const ImageType *>(this->itk::ProcessObject::GetInput(1));
57 }
58 
59 template <class TPath, class TImage>
60 void
63 {
64  // I/O wiring
65  ImageConstPointerType inputImagePtr = this->GetInputImage();
66  const PathListType * inputPtr = this->GetInput();
67  PathListType * outputPtr = this->GetOutput();
68 
70 
71  for (IteratorType it = inputPtr->Begin(); it != inputPtr->End(); ++it)
72  {
73  PathPointerType path = it.Get();
74  ImageIteratorType imageIt(inputImagePtr, path);
75  double cumulatedValues = 0.0;
76  double nbPoints = 0.0;
77  for (imageIt.GoToBegin(); !imageIt.IsAtEnd(); ++imageIt, ++nbPoints)
78  {
79  cumulatedValues += static_cast<double>(imageIt.Get());
80  }
81  itk::MetaDataDictionary& dict = path->GetMetaDataDictionary();
82  itk::EncapsulateMetaData<double>(dict, m_Key, cumulatedValues / nbPoints);
83  outputPtr->PushBack(path);
84  }
85 }
89 template <class TPath, class TImage>
90 void
92 ::PrintSelf(std::ostream& os, itk::Indent indent) const
93 {
94  Superclass::PrintSelf(os, indent);
95 }
96 
97 } // End namespace otb
98 #endif

Generated at Sat Aug 30 2014 16:11:14 for Orfeo Toolbox with doxygen 1.8.3.1