OTB  9.0.0
Orfeo Toolbox
otbSOMActivationBuilder.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 otbSOMActivationBuilder_hxx
22 #define otbSOMActivationBuilder_hxx
23 
25 #include "itkImageRegionIterator.h"
26 
27 namespace otb
28 {
32 template <class TInputImage, class TInputMap, class TOutputImage>
34 {
35  this->SetNumberOfRequiredInputs(1);
36  this->SetNthOutput(0, OutputImageType::New());
37 }
38 
42 template <class TInputImage, class TInputMap, class TOutputImage>
44 {
45 }
46 
50 template <class TInputImage, class TInputMap, class TOutputImage>
52 {
53  // Retrieve the inputs and output pointers
54  InputMapType* map = const_cast<InputMapType*>(this->GetInput());
55  OutputImagePointerType output = this->GetOutput();
57 
58  // output initialization
59  output->SetRegions(map->GetLargestPossibleRegion());
60  output->Allocate();
61  output->FillBuffer(static_cast<typename OutputImageType::PixelType>(0));
62 
63  // Iterator typedef
64  typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
65  typename InputMapType::IndexType index;
66  // Iterators instantiation
67  OutputIteratorType outIt(output, output->GetLargestPossibleRegion());
68 
69  // For each vector in the set
70  for (typename ListSampleType::Iterator it = m_ListSample->Begin(); it != m_ListSample->End(); ++it)
71  {
72  // Retrieve the index of the winner
73  index = map->GetWinner(it.GetMeasurementVector());
74  // increment the activation map
75  outIt.SetIndex(index);
76  outIt.Set(outIt.Get() + 1);
77  }
78 }
otb::SOMActivationBuilder::~SOMActivationBuilder
~SOMActivationBuilder() override
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SOMActivationBuilder::GenerateData
void GenerateData(void) override
otb::SOMActivationBuilder::SOMActivationBuilder
SOMActivationBuilder()
otbSOMActivationBuilder.h