OTB  7.2.0
Orfeo Toolbox
otbAngularProjectionSetImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbAngularProjectionSetImageFilter_hxx
22 #define otbAngularProjectionSetImageFilter_hxx
24 
25 #include <vnl/vnl_math.h>
26 
27 #include <itkImageRegionIterator.h>
28 
29 namespace otb
30 {
31 
32 template <class TInputImage, class TOutputImage, class TAngleList, class TPrecision>
34 {
35  // this->SetNumberOfRequiredInputs( NumberOfInputImages );
36  this->SetNumberOfRequiredOutputs(1);
37  this->SetNthOutput(0, OutputImageListType::New());
38 
39  m_FilterList = FilterListType::New();
40  m_AngleList = AngleListType::New();
41 }
42 
43 template <class TInputImage, class TOutputImage, class TAngleList, class TPrecision>
45 {
46  this->itk::ProcessObject::SetNthInput(i, const_cast<InputImageType*>(img));
47 }
48 
49 template <class TInputImage, class TOutputImage, class TAngleList, class TPrecision>
51 {
52  if (i >= this->GetNumberOfInputs())
53  {
54  return nullptr;
55  }
56 
57  return static_cast<const InputImageType*>(this->itk::ProcessObject::GetInput(i));
58 }
59 
60 
61 template <class TInputImage, class TOutputImage, class TAngleList, class TPrecision>
63 {
64  itk::ProgressAccumulator::Pointer progress = itk::ProgressAccumulator::New();
65  progress->SetMiniPipelineFilter(this);
66 
67  std::cerr << "Using " << GetAngleList()->Size() << " outputs...\n";
68  GetFilterList()->Resize(GetAngleList()->Size());
69  this->GetOutput()->Resize(GetAngleList()->Size());
70 
71  for (unsigned int idx = 0; idx < GetFilterList()->Size(); ++idx)
72  {
73  GetFilterList()->SetNthElement(0, FilterType::New());
74  FilterPointerType filter = GetFilterList()->GetNthElement(0);
75  for (unsigned int i = 0; i < this->GetNumberOfInputs(); ++i)
76  filter->SetInput(i, this->GetInput(i));
77  filter->SetAngleArray(GetAngleList()->GetMeasurementVector(idx));
78 
79  progress->RegisterInternalFilter(filter, 1.f / static_cast<float>(GetAngleList()->Size()));
80 
81  filter->Update();
82 
83  this->GetOutput()->SetNthElement(idx, filter->GetOutput());
84  }
85 }
86 
87 } // end of namespace otb
88 
89 #endif
void SetInput(unsigned int i, const InputImageType *)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
InputImageType * GetInput(void)