OTB  9.0.0
Orfeo Toolbox
otbStreamingLineSegmentDetector.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  *
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 otbStreamingLineSegmentDetector_hxx
23 #define otbStreamingLineSegmentDetector_hxx
24 
26 
28 #include "itkAffineTransform.h"
29 
30 namespace otb
31 {
32 
33 template <class TInputImage>
35 {
36 }
37 
38 template <class TInputImage>
40 {
41 }
42 
43 template <class TInputImage>
45 {
46  Superclass::GenerateInputRequestedRegion();
47 
48  if (this->GetInput())
49  {
50  InputImagePointerType input = const_cast<InputImageType*>(this->GetInput());
51 
52  typename InputImageType::RegionType region = this->GetOutput()->GetRequestedRegion();
53 
54  region.PadByRadius(1);
55  region.Crop(input->GetLargestPossibleRegion());
56 
57  input->SetRequestedRegion(region);
58  }
59 }
60 
61 template <class TInputImage>
63 {
64  // Apply an ExtractImageFilter to avoid problems with filters asking for the LargestPossibleRegion
65  typename ExtractImageFilterType::Pointer extract = ExtractImageFilterType::New();
66  extract->SetInput(this->GetInput());
67  extract->SetExtractionRegion(this->GetInput()->GetBufferedRegion());
68  extract->Update();
69 
70  // WARNING: itk::ExtractImageFilter does not copy the MetadataDictionary
71  // but LSD filter need the projection ref if available
72  extract->GetOutput()->SetMetaDataDictionary(this->GetInput()->GetMetaDataDictionary());
73 
74  typename LSDType::Pointer lsd = LSDType::New();
75  lsd->SetInput(extract->GetOutput());
76  lsd->UpdateOutputInformation();
77  lsd->Update();
78 
79  // return the LSD VectorData in image physical coordinates
80  return lsd->GetOutput();
81 }
82 
83 
84 } // end namespace otb
85 #endif
otb::PersistentStreamingLineSegmentDetector::InputImageType
Superclass::InputImageType InputImageType
Definition: otbStreamingLineSegmentDetector.h:63
otb::LineSegmentDetector< TImageType, double >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLineSegmentDetector.h:98
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PersistentStreamingLineSegmentDetector::PersistentStreamingLineSegmentDetector
PersistentStreamingLineSegmentDetector()
Definition: otbStreamingLineSegmentDetector.hxx:34
otb::PersistentStreamingLineSegmentDetector::InputImagePointerType
Superclass::InputImagePointer InputImagePointerType
Definition: otbStreamingLineSegmentDetector.h:64
otb::PersistentStreamingLineSegmentDetector::ProcessTile
OutputVectorDataPointerType ProcessTile() override
Definition: otbStreamingLineSegmentDetector.hxx:62
otbVectorDataTransformFilter.h
otb::PersistentStreamingLineSegmentDetector::~PersistentStreamingLineSegmentDetector
~PersistentStreamingLineSegmentDetector() override
Definition: otbStreamingLineSegmentDetector.hxx:39
otb::PersistentStreamingLineSegmentDetector::OutputVectorDataPointerType
Superclass::OutputVectorDataPointerType OutputVectorDataPointerType
Definition: otbStreamingLineSegmentDetector.h:67
otbStreamingLineSegmentDetector.h
otb::PersistentStreamingLineSegmentDetector::GenerateInputRequestedRegion
void GenerateInputRequestedRegion() override
Definition: otbStreamingLineSegmentDetector.hxx:44