OTB  9.0.0
Orfeo Toolbox
otbSOMMap.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  * Copyright (C) 2007-2012 Institut Mines Telecom / Telecom Bretagne
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbSOMMap_hxx
23 #define otbSOMMap_hxx
24 
25 #include "otbSOMMap.h"
26 #include "itkImageRegionIteratorWithIndex.h"
27 
28 namespace otb
29 {
33 template <class TNeuron, class TDistance, unsigned int VMapDimension>
35 {
36 }
37 
41 template <class TNeuron, class TDistance, unsigned int VMapDimension>
43 {
44 }
45 
51 template <class TNeuron, class TDistance, unsigned int VMapDimension>
53 {
54  // Some typedefs
55  typedef itk::ImageRegionIteratorWithIndex<Self> IteratorType;
56 
57  // Define the euclidean distance used to compute the neural response
58  DistancePointerType activation = DistanceType::New();
59 
60  // Define the iterator used to walk through the map
61  IteratorType it(this, this->GetLargestPossibleRegion());
62  it.GoToBegin();
63 
64  // Define the minimum distance and position
65  IndexType minPos = it.GetIndex();
66 
67  double minDistance = activation->Evaluate(sample, it.Get());
68 
69  // Iterate through the map to get the minimum distance position
70  for (; !it.IsAtEnd(); ++it)
71  {
72  double tempDistance = activation->Evaluate(sample, it.Get());
73  if (tempDistance <= minDistance)
74  {
75  minDistance = tempDistance;
76  minPos = it.GetIndex();
77  }
78  }
79  // Return the index of the winner
80  return minPos;
81 }
82 template <class TNeuron, class TDistance, unsigned int VMapDimension>
83 void SOMMap<TNeuron, TDistance, VMapDimension>::PrintSelf(std::ostream& os, itk::Indent indent) const
84 {
85  Superclass::PrintSelf(os, indent);
86 }
87 } // end namespace otb
88 #endif
otb::SOMMap::IndexType
Superclass::IndexType IndexType
Definition: otbSOMMap.h:78
otbSOMMap.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SOMMap::DistancePointerType
DistanceType::Pointer DistancePointerType
Definition: otbSOMMap.h:75
otb::SOMMap::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSOMMap.hxx:83
otb::SOMMap::~SOMMap
~SOMMap() override
Definition: otbSOMMap.hxx:42
otb::SOMMap::GetWinner
IndexType GetWinner(const NeuronType &sample)
Definition: otbSOMMap.hxx:52
otb::SOMMap::SOMMap
SOMMap()
Definition: otbSOMMap.hxx:34
otb::SOMMap::NeuronType
TNeuron NeuronType
Definition: otbSOMMap.h:64