Orfeo Toolbox  4.0
otbVectorDataToRoadDescriptionFilter.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 __otbVectorDataToRoadDescriptionFilter_txx
19 #define __otbVectorDataToRoadDescriptionFilter_txx
20 
22 
23 namespace otb
24 {
25 
26 // Constructor
27 template <class TVectorData, class TOpticalImage>
30 {
31  this->SetNumberOfRequiredInputs(3);
32 
33  m_NDVIFeatureFunction = ParserConditionFeatureFunctionType::New();
34  m_NDVIFeatureFunction->SetExpression("ndvi(b3, b4) > 0.4");
35 
36  m_SpectralAngleFeatureFunction = ParserConditionFeatureFunctionType::New();
37  m_SpectralAngleFeatureFunction->SetExpression("spectralAngle > 0.25");
38 
39  //Example for QuickBird images (on a specific image)
41  refPixel.SetSize(4);
42  refPixel[0] = 252;
43  refPixel[1] = 357;
44  refPixel[2] = 232;
45  refPixel[3] = 261;
46  m_SpectralAngleFeatureFunction->SetSpectralAngleReferencePixel(refPixel);
47 
48  m_DBOverlapFeatureFunction = DBOverlapFeatureFunctionType::New();
49 
50  m_DescriptorsList.push_back("NONDVI");
51  m_DescriptorsList.push_back("ROADSA");
52  m_DescriptorsList.push_back("NOBUIL");
53 }
54 
55 template <class TVectorData, class TOpticalImage>
56 void
59 {
60  this->AddSupport(const_cast<OpticalImageType *>(support), 0);
61 }
62 
63 template <class TVectorData, class TOpticalImage>
65 ::OpticalImageType *
68 {
69  return static_cast<const OpticalImageType *>
70  (this->GetSupport(0));
71 }
72 
73 
74 template <class TVectorData, class TOpticalImage>
75 void
78 {
79  this->AddSupport(const_cast<VectorDataType *>(support), 1);
80 }
81 
82 template <class TVectorData, class TOpticalImage>
87 {
88  return static_cast<const VectorDataType *>
89  (this->GetSupport(1));
90 }
91 
92 template <class TVectorData, class TOpticalImage>
93 void
96 {
97  m_NDVIFeatureFunction->SetInputImage(const_cast<OpticalImageType *>(this->GetOpticalImage()));
98  m_SpectralAngleFeatureFunction->SetInputImage(const_cast<OpticalImageType *>(this->GetOpticalImage()));
99  m_DBOverlapFeatureFunction->SetInputVectorData(const_cast<VectorDataType *>(this->GetBuildingsDB()));
100 
101  // Retrieving root node
102  typename DataNodeType::Pointer root = this->GetOutput(0)->GetDataTree()->GetRoot()->Get();
103  // Create the document node
104  typename DataNodeType::Pointer document = DataNodeType::New();
105  document->SetNodeType(otb::DOCUMENT);
106  // Adding the layer to the data tree
107  this->GetOutput(0)->GetDataTree()->Add(document, root);
108  // Create the folder node
109  typename DataNodeType::Pointer folder = DataNodeType::New();
110  folder->SetNodeType(otb::FOLDER);
111  // Adding the layer to the data tree
112  this->GetOutput(0)->GetDataTree()->Add(folder, document);
113 
114  TreeIteratorType itVector(this->GetInput()->GetDataTree());
115  itVector.GoToBegin();
116  while (!itVector.IsAtEnd())
117  {
118  if (!itVector.Get()->IsRoot() && !itVector.Get()->IsDocument() && !itVector.Get()->IsFolder())
119  {
120  typename DataNodeType::Pointer currentGeometry = itVector.Get();
121  currentGeometry->SetFieldAsDouble("NONDVI", (double)(m_NDVIFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
122  currentGeometry->SetFieldAsDouble("ROADSA", (double)(m_SpectralAngleFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
123  currentGeometry->SetFieldAsDouble("NOBUIL", (double)(m_DBOverlapFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
124 
125  this->GetOutput(0)->GetDataTree()->Add(currentGeometry, folder);
126  }
127  ++itVector;
128  }
129 }
130 
131 // PrintSelf Method
132 template <class TVectorData, class TOpticalImage>
133 void
135 ::PrintSelf(std::ostream& os, itk::Indent indent) const
136 {
137  Superclass::PrintSelf(os, indent);
138 }
139 
140 } // end namespace otb
141 
142 #endif

Generated at Sat Mar 8 2014 16:24:45 for Orfeo Toolbox with doxygen 1.8.3.1