OTB  9.0.0
Orfeo Toolbox
otbSiftFastImageFilter.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 
22 #ifndef otbSiftFastImageFilter_hxx
23 #define otbSiftFastImageFilter_hxx
24 
25 #include "otbSiftFastImageFilter.h"
26 
27 #include "otb_siftfast.h"
28 #include "itkContinuousIndex.h"
29 #include "itkImageRegionConstIterator.h"
30 
31 namespace otb
32 {
36 template <class TInputImage, class TOutputPointSet>
38 {
39 }
40 
41 template <class TInputImage, class TOutputPointSet>
43 {
44 
45  // Get the input image pointer
46  const InputImageType* inputPtr = this->GetInput();
47  OutputPointSetPointerType outputPointSet = this->GetOutput();
48 
49  typename InputImageType::SizeType size = inputPtr->GetLargestPossibleRegion().GetSize();
50 
51  SiftFastImage siftInputImage = CreateImage(size[1], size[0]);
52  itk::ImageRegionConstIterator<TInputImage> inIt(inputPtr, inputPtr->GetBufferedRegion());
53 
54  unsigned int index = 0;
55 
56  for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt)
57  {
58  siftInputImage->pixels[index] = static_cast<float>(inIt.Get());
59  ++index;
60  }
61 
62  Keypoint keypts = GetKeypoints(siftInputImage, m_ScalesNumber);
63 
64  Keypoint key = keypts;
65 
66  unsigned int numkeys = 0;
67 
68  while (key)
69  {
70  // Get the key location
71  itk::ContinuousIndex<float, 2> keyContIndex;
72  keyContIndex[0] = key->col;
73  keyContIndex[1] = key->row;
74 
75  OutputPointType point;
76  inputPtr->TransformContinuousIndexToPhysicalPoint(keyContIndex, point);
77 
78  // Get the key descriptor
79  OutputPixelType data;
80  data.SetSize(128);
81  for (int i = 0; i < 128; ++i)
82  {
83  data[i] = key->descrip[i];
84  }
85  outputPointSet->SetPoint(numkeys, point);
86  outputPointSet->SetPointData(numkeys, data);
87 
88  // Fill the current point and its orientation
89  std::pair<OutputPointType, double> pair;
90  pair.first = point;
91  pair.second = key->ori;
92  m_OrientationVector.push_back(pair);
93 
94  // std::cout << " In SiftFastimageFilter : point " << point << " have orientation " << key->ori<< std::endl;
95 
96  // go to next key
97  ++numkeys;
98  key = key->next;
99  }
100  FreeKeypoints(keypts);
101  DestroyAllResources();
102 }
103 /*
104  * PrintSelf Method
105  */
106 template <class TInputImage, class TOutputPointSet>
107 void SiftFastImageFilter<TInputImage, TOutputPointSet>::PrintSelf(std::ostream& os, itk::Indent indent) const
108 {
109  Superclass::PrintSelf(os, indent);
110 }
111 
112 } // End namespace otb
113 
114 #endif
otb::SiftFastImageFilter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSiftFastImageFilter.hxx:107
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbSiftFastImageFilter.h
otb::ImageToPointSetFilter::InputImageType
TInputImage InputImageType
Definition: otbImageToPointSetFilter.h:54
otb::SiftFastImageFilter::OutputPointSetPointerType
TOutputPointSet::Pointer OutputPointSetPointerType
Definition: otbSiftFastImageFilter.h:74
otb::SiftFastImageFilter::OutputPointType
TOutputPointSet::PointType OutputPointType
Definition: otbSiftFastImageFilter.h:76
otb::SiftFastImageFilter::SiftFastImageFilter
SiftFastImageFilter()
Definition: otbSiftFastImageFilter.hxx:37
otb::SiftFastImageFilter::OutputPixelType
TOutputPointSet::PixelType OutputPixelType
Definition: otbSiftFastImageFilter.h:75
otb::SiftFastImageFilter::GenerateData
void GenerateData() override
Definition: otbSiftFastImageFilter.hxx:42