OTB  6.7.0
Orfeo Toolbox
otbAngularProjectionSetImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 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 >
44 void
46 ::SetInput ( unsigned int i, const InputImageType * img )
47 {
49  const_cast< InputImageType * >( img ) );
50 }
51 
52 template < class TInputImage, class TOutputImage, class TAngleList, class TPrecision >
53 const TInputImage *
55 ::GetInput ( unsigned int i ) const
56 {
57  if ( i >= this->GetNumberOfInputs() )
58  {
59  return nullptr;
60  }
61 
62  return static_cast<const InputImageType * >
63  (this->itk::ProcessObject::GetInput(i) );
64 }
65 
66 
67 template < class TInputImage, class TOutputImage, class TAngleList, class TPrecision >
68 void
71 {
73  progress->SetMiniPipelineFilter(this);
74 
75  std::cerr << "Using " << GetAngleList()->Size() << " outputs...\n";
76  GetFilterList()->Resize( GetAngleList()->Size() );
77  this->GetOutput()->Resize( GetAngleList()->Size() );
78 
79  for ( unsigned int idx = 0; idx < GetFilterList()->Size(); ++idx )
80  {
81  GetFilterList()->SetNthElement(0, FilterType::New());
82  FilterPointerType filter = GetFilterList()->GetNthElement(0);
83  for ( unsigned int i = 0; i < this->GetNumberOfInputs(); ++i )
84  filter->SetInput( i, this->GetInput(i) );
85  filter->SetAngleArray( GetAngleList()->GetMeasurementVector(idx) );
86 
87  progress->RegisterInternalFilter(filter, 1.f/static_cast<float>( GetAngleList()->Size() ) );
88 
89  filter->Update();
90 
91  this->GetOutput()->SetNthElement( idx, filter->GetOutput() );
92  }
93 }
94 
95 } // end of namespace otb
96 
97 #endif
98 
99 
void SetInput(unsigned int i, const InputImageType *)
static Pointer New()
DataObject * GetInput(const DataObjectIdentifierType &key)
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
InputImageType * GetInput(void)