22 #ifndef otbDEMCaracteristicsExtractor_hxx
23 #define otbDEMCaracteristicsExtractor_hxx
26 #include "itkImageRegionIterator.h"
32 template <
class TInputImage,
class TOutputImage>
35 this->SetNumberOfRequiredInputs(1);
36 this->SetNumberOfRequiredOutputs(3);
38 this->SetNthOutput(0, OutputImageType::New());
39 this->SetNthOutput(1, OutputImageType::New());
40 this->SetNthOutput(2, OutputImageType::New());
41 this->SetNthOutput(3, OutputImageType::New());
49 template <
class TInputImage,
class TOutputImage>
57 template <
class TInputImage,
class TOutputImage>
61 typename InputImageType::Pointer inputPtr =
const_cast<InputImageType*
>(this->GetInput());
62 typename OutputImageType::Pointer SlopOutputPtr = this->GetSlopOutput();
63 typename OutputImageType::Pointer AspectOutputPtr = this->GetAspectOutput();
64 typename OutputImageType::Pointer IncidenceOutputPtr = this->GetIncidenceOutput();
65 typename OutputImageType::Pointer ExitanceOutputPtr = this->GetExitanceOutput();
69 typename GradientMagnitudeFilterType::Pointer GradientMagnitudeFilter = GradientMagnitudeFilterType::New();
71 typename GradientRecursiveGaussianImageFilterType::Pointer GradientRecursiveGaussianFilter = GradientRecursiveGaussianImageFilterType::New();
73 typename AtanFilterType::Pointer AtanFilter = AtanFilterType::New();
75 typename Atan2FilterType::Pointer AspectFilter = Atan2FilterType::New();
77 typename AcosImageFilterType::Pointer IncidenceFilter = AcosImageFilterType::New();
79 typename AcosImageFilterType::Pointer ExitanceFilter = AcosImageFilterType::New();
86 GradientMagnitudeFilter->SetInput(inputPtr);
87 AtanFilter->SetInput(GradientMagnitudeFilter->GetOutput());
91 rad2DegFilter->SetInput(AtanFilter->GetOutput());
92 rad2DegFilter->SetCoef(rad2degCoef);
93 rad2DegFilter->GraftOutput(SlopOutputPtr);
94 rad2DegFilter->Update();
95 this->GraftNthOutput(0, rad2DegFilter->GetOutput());
98 GradientRecursiveGaussianFilter->SetInput(inputPtr);
99 GradientRecursiveGaussianFilter->Update();
102 typename AdaptorType::Pointer XAdaptator = AdaptorType::New();
103 typename AdaptorType::Pointer YAdaptator = AdaptorType::New();
104 XAdaptator->SetImage(GradientRecursiveGaussianFilter->GetOutput());
105 YAdaptator->SetImage(GradientRecursiveGaussianFilter->GetOutput());
106 XAdaptator->SelectNthElement(0);
107 YAdaptator->SelectNthElement(1);
109 AspectFilter->SetInput1(XAdaptator);
110 AspectFilter->SetInput2(YAdaptator);
113 rad2DegFilter1->SetInput(AspectFilter->GetOutput());
114 rad2DegFilter1->SetCoef(rad2degCoef);
115 rad2DegFilter1->GraftOutput(AspectOutputPtr);
116 rad2DegFilter1->Update();
117 this->GraftNthOutput(1, rad2DegFilter1->GetOutput());
121 typename SinImageFilterType::Pointer sinS = SinImageFilterType::New();
122 sinS->SetInput(GradientMagnitudeFilter->GetOutput());
124 typename CosImageFilterType::Pointer cosS = CosImageFilterType::New();
125 cosS->SetInput(GradientMagnitudeFilter->GetOutput());
128 oppositeFilter->SetInput(AspectFilter->GetOutput());
129 oppositeFilter->SetCoef(-1);
132 typename ShiftScaleImageFilterType::Pointer addAzimut = ShiftScaleImageFilterType::New();
133 addAzimut->SetScale(1.);
134 addAzimut->SetShift(m_SolarAzimut / rad2degCoef);
135 addAzimut->SetInput(oppositeFilter->GetOutput());
137 typename CosImageFilterType::Pointer cosAAzimut = CosImageFilterType::New();
138 cosAAzimut->SetInput(addAzimut->GetOutput());
141 sinSsinSolarAngleFilter->SetCoef(std::sin(m_SolarAngle / rad2degCoef));
142 sinSsinSolarAngleFilter->SetInput(sinS->GetOutput());
144 typename MultiplyImageFilterType::Pointer cosAAzimuthsinSsinAngle = MultiplyImageFilterType::New();
145 cosAAzimuthsinSsinAngle->SetInput1(sinSsinSolarAngleFilter->GetOutput());
146 cosAAzimuthsinSsinAngle->SetInput2(cosAAzimut->GetOutput());
149 cosScosSolarAngleFilter->SetCoef(std::cos(m_SolarAngle / rad2degCoef));
150 cosScosSolarAngleFilter->SetInput(cosS->GetOutput());
152 typename AddImageFilterType::Pointer cosIncidence = AddImageFilterType::New();
153 cosIncidence->SetInput1(cosAAzimuthsinSsinAngle->GetOutput());
154 cosIncidence->SetInput2(cosScosSolarAngleFilter->GetOutput());
156 IncidenceFilter->SetInput(cosIncidence->GetOutput());
160 rad2DegFilter2->SetInput(IncidenceFilter->GetOutput());
161 rad2DegFilter2->SetCoef(rad2degCoef);
163 rad2DegFilter2->GraftOutput(IncidenceOutputPtr);
164 rad2DegFilter2->Update();
165 this->GraftNthOutput(2, rad2DegFilter2->GetOutput());
168 typename ShiftScaleImageFilterType::Pointer addAzimut2 = ShiftScaleImageFilterType::New();
169 addAzimut2->SetScale(1.);
170 addAzimut2->SetShift(m_ViewAzimut / rad2degCoef);
171 addAzimut2->SetInput(oppositeFilter->GetOutput());
173 typename CosImageFilterType::Pointer cosAAzimut2 = CosImageFilterType::New();
174 cosAAzimut2->SetInput(addAzimut2->GetOutput());
177 sinSsinSolarAngleFilter2->SetCoef(std::sin(m_ViewAngle / rad2degCoef));
178 sinSsinSolarAngleFilter2->SetInput(sinS->GetOutput());
180 typename MultiplyImageFilterType::Pointer cosAAzimuthsinSsinAngle2 = MultiplyImageFilterType::New();
181 cosAAzimuthsinSsinAngle2->SetInput1(sinSsinSolarAngleFilter2->GetOutput());
182 cosAAzimuthsinSsinAngle2->SetInput2(cosAAzimut2->GetOutput());
185 cosScosSolarAngleFilter2->SetCoef(std::cos(m_ViewAngle / rad2degCoef));
186 cosScosSolarAngleFilter2->SetInput(cosS->GetOutput());
188 typename AddImageFilterType::Pointer cosIncidence2 = AddImageFilterType::New();
189 cosIncidence2->SetInput1(cosAAzimuthsinSsinAngle2->GetOutput());
190 cosIncidence2->SetInput2(cosScosSolarAngleFilter2->GetOutput());
192 ExitanceFilter->SetInput(cosIncidence2->GetOutput());
196 rad2DegFilter3->SetInput(ExitanceFilter->GetOutput());
197 rad2DegFilter3->SetCoef(rad2degCoef);
199 rad2DegFilter3->GraftOutput(ExitanceOutputPtr);
200 rad2DegFilter3->Update();
201 this->GraftNthOutput(3, rad2DegFilter3->GetOutput());
205 template <
class TInputImage,
class TOutputImage>
208 Superclass::PrintSelf(os, indent);
209 os << indent <<
"Solar Angle: " << m_SolarAngle << std::endl;
210 os << indent <<
"Solar Azimut: " << m_SolarAzimut << std::endl;
211 os << indent <<
"View Angle: " << m_ViewAngle << std::endl;
212 os << indent <<
"View Azimut: " << m_ViewAzimut << std::endl;