OTB  10.0.0
Orfeo Toolbox
otbSummingFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2024 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 __SummingFilter_hxx
23 #define __SummingFilter_hxx
24 
25 #include "otbSummingFilter.h"
26 #include "itkProgressReporter.h"
27 
28 namespace otb
29 {
30 
34 template <class TInputImage, class TOutputImage>
36 {
37  itkDebugMacro(<< "Generate output information");
38  Superclass::GenerateOutputInformation();
39 }
41 
45 template <class TInputImage, class TOutputImage>
47 {
48  // Iterate through the thread region
49  OutputIteratorType outputIt(this->GetOutput(), outputRegionForThread);
50 
51  // Prepare input iterators
52  unsigned int nbInputImages = this->GetNumberOfInputs();
53  unsigned int nbInputBands;
54 
55  InputIteratorType inputIt[nbInputImages];
56  for (unsigned int i = 0; i < nbInputImages; i++)
57  {
58  InputImageType* currentImage = const_cast<InputImageType*>(this->GetInput(i));
59  inputIt[i] = InputIteratorType(currentImage, outputRegionForThread);
60  nbInputBands = currentImage->GetNumberOfComponentsPerPixel();
61  }
62 
64  pix.SetSize(nbInputBands);
65 
66  // Sum images
67  for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt)
68  {
69  pix.Fill(0.0);
70  for (unsigned int i = 0; i < nbInputImages; i++)
71  {
72 
73  for (unsigned int band = 0; band < nbInputBands; band++)
74  {
75  pix[band] += inputIt[i].Get()[band];
76  }
77  ++inputIt[i];
78  }
79  outputIt.Set(pix);
80  }
81 }
82 }
83 
84 #endif
virtual void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread)
TInputImage InputImageType
OutputImageType::RegionType OutputImageRegionType
itk::ImageRegionConstIterator< InputImageType > InputIteratorType
itk::ImageRegionIterator< OutputImageType > OutputIteratorType
OutputImageType::PixelType OutputImagePixelType
virtual void GenerateOutputInformation(void)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.