OTB  9.0.0
Orfeo Toolbox
otbStreamingMosaicFilterWithBlendingBase.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
4  * Copyright (C) 2016-2019 IRSTEA
5  *
6  * This file is part of Orfeo Toolbox
7  *
8  * https://www.orfeo-toolbox.org/
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 #ifndef __StreamingMosaicFilterWithBlendingBase_hxx
23 #define __StreamingMosaicFilterWithBlendingBase_hxx
24 
26 
27 namespace otb
28 {
29 
30 template <class TInputImage, class TOutputImage, class TDistanceImage, class TInternalValueType>
32 {
33 
34  // Default distance offset
35  m_DistanceOffset = 0.0;
36 
37  // Default interpolator
38  typename DistanceImageDefaultInterpolatorType::Pointer interp = DistanceImageDefaultInterpolatorType::New();
39  m_DistanceInterpolator = static_cast<DistanceImageInterpolatorType*>(interp.GetPointer());
40 }
41 
42 /*
43  * This method is overridden because one index on two is not an input image, but
44  * an input distance image
45  */
46 template <class TInputImage, class TOutputImage, class TDistanceImage, class TInternalValueType>
48 {
49  // Add this index only if input is an inputImage (i.e. not a distanceImage)
50  if (inputImageIndex % 2 == 0)
51  {
52  itkDebugMacro(<< "Input #" << inputImageIndex << " is an InputImage and will be used");
53  Superclass::AddUsedInputImageIndex(inputImageIndex);
54  }
55  else
56  {
57  itkDebugMacro(<< "Input #" << inputImageIndex << " is an DistanceImage and will NOT be used");
58  }
59 }
60 
61 /*
62  * This method is overridden because there is twice less input images
63  * (1 input image on 2 is a DistanceImage)
64  */
65 template <class TInputImage, class TOutputImage, class TDistanceImage, class TInternalValueType>
67 {
68  return 0.5 * this->GetNumberOfInputs();
69 }
70 
71 /*
72  * Prepare:
73  * 1 image pointer
74  * 1 image interpolator
75  * 1 image region, which correspond to the buffered region which can be used by the interpolator
76  */
77 template <class TInputImage, class TOutputImage, class TDistanceImage, class TInternalValueType>
79  typename std::vector<DistanceImageType*>& currentDistanceImage, typename std::vector<DistanceImageInterpolatorPointer>& distanceInterpolator)
80 {
81 
82  // Get number of used input images
83  const unsigned int n = Superclass::GetNumberOfUsedInputImages();
84 
85  currentDistanceImage.reserve(n);
86  distanceInterpolator.reserve(n);
87 
88  // Loop on input images
89  for (unsigned int i = 0; i < n; i++)
90  {
91  // Input distance image i
92  currentDistanceImage.push_back(static_cast<DistanceImageType*>(Superclass::ProcessObject::GetInput(Superclass::GetUsedInputImageIndice(i) + 1)));
93 
94  // Distance interpolator i
95  distanceInterpolator.push_back(static_cast<DistanceImageInterpolatorType*>((m_DistanceInterpolator->CreateAnother()).GetPointer()));
96  distanceInterpolator[i]->SetInputImage(currentDistanceImage[i]);
97  }
98 }
99 
100 } // end namespace otb
101 
102 #endif
otbStreamingMosaicFilterWithBlendingBase.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::StreamingMosaicFilterWithBlendingBase< TInputImage, TOutputImage, TDistanceImage, double >::DistanceImageInterpolatorType
itk::InterpolateImageFunction< DistanceImageType > DistanceImageInterpolatorType
Definition: otbStreamingMosaicFilterWithBlendingBase.h:68
otb::StreamingMosaicFilterWithBlendingBase::PrepareDistanceImageAccessors
virtual void PrepareDistanceImageAccessors(typename std::vector< DistanceImageType * > &currentDistanceImage, typename std::vector< DistanceImageInterpolatorPointer > &distanceInterpolator)
Definition: otbStreamingMosaicFilterWithBlendingBase.hxx:78
otb::StreamingMosaicFilterWithBlendingBase::AddUsedInputImageIndex
void AddUsedInputImageIndex(unsigned int inputImageIndex) override
Definition: otbStreamingMosaicFilterWithBlendingBase.hxx:47
otb::StreamingMosaicFilterWithBlendingBase< TInputImage, TOutputImage, TDistanceImage, double >::DistanceImageType
TDistanceImage DistanceImageType
Definition: otbStreamingMosaicFilterWithBlendingBase.h:59
otb::StreamingMosaicFilterWithBlendingBase::StreamingMosaicFilterWithBlendingBase
StreamingMosaicFilterWithBlendingBase()
Definition: otbStreamingMosaicFilterWithBlendingBase.hxx:31
otb::StreamingMosaicFilterWithBlendingBase::GetNumberOfInputImages
unsigned int GetNumberOfInputImages() override
Definition: otbStreamingMosaicFilterWithBlendingBase.hxx:66