OTB  5.0.0
Orfeo Toolbox
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 
25 namespace otb
26 {
30 template <class TPath, class TImage>
33 {
34  m_Key = "Value";
35  this->SetNumberOfRequiredInputs(2);
36  this->SetNumberOfRequiredInputs(2);
37 }
38 template <class TPath, class TImage>
39 void
41 ::SetInputImage(const ImageType * image)
42 {
43  this->itk::ProcessObject::SetNthInput(1, const_cast<ImageType *>(image));
44 }
45 template <class TPath, class TImage>
47 ::ImageType *
50 {
51  if (this->GetNumberOfInputs() < 1)
52  {
53  return 0;
54  }
55  return static_cast<const ImageType *>(this->itk::ProcessObject::GetInput(1));
56 }
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
PathListType::ConstIterator IteratorType
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Uses the bresenham algorithm to iterate over a polyline on an image (const version).
Affect a value to each path of the list based on the image.
DataObject * GetInput(const DataObjectIdentifierType &key)
void SetInputImage(const ImageType *image)
Superclass::InputListType PathListType
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
ImageType::ConstPointer ImageConstPointerType