OTB  9.0.0
Orfeo Toolbox
otbLabelImageRegionMergingFilter.h
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 otbLabelImageRegionMergingFilter_h
22 #define otbLabelImageRegionMergingFilter_h
23 
24 #include "otbImage.h"
25 #include "otbVectorImage.h"
26 #include "itkImageToImageFilter.h"
27 
28 #include <set>
29 
30 namespace otb
31 {
32 
44 template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage = TInputLabelImage, class TOutputClusteredImage = TInputSpectralImage>
45 class ITK_EXPORT LabelImageRegionMergingFilter : public itk::ImageToImageFilter<TInputLabelImage, TOutputLabelImage>
46 {
47 public:
50  typedef itk::ImageToImageFilter<TInputLabelImage, TOutputLabelImage> Superclass;
51  typedef itk::SmartPointer<Self> Pointer;
52  typedef itk::SmartPointer<const Self> ConstPointer;
53  typedef double RealType;
54 
56  itkTypeMacro(LabelImageRegionMergingFilter, ImageToImageFilter);
57  itkNewMacro(Self);
59 
61  typedef TInputLabelImage InputLabelImageType;
62  typedef typename InputLabelImageType::PixelType InputLabelType;
63 
64  typedef TInputLabelImage InputImageType;
65  typedef typename InputImageType::Pointer InputImagePointerType;
66  typedef typename InputImageType::PixelType InputPixelType;
67  typedef typename InputImageType::IndexType InputIndexType;
68  typedef typename InputImageType::SizeType InputSizeType;
69  typedef typename InputImageType::IndexValueType InputIndexValueType;
70  typedef typename InputImageType::PointType PointType;
71  typedef typename InputImageType::RegionType RegionType;
72  typedef typename InputImageType::SizeType SizeType;
73 
74  typedef TInputSpectralImage InputSpectralImageType;
75  typedef typename TInputSpectralImage::PixelType SpectralPixelType;
76 
77  typedef TOutputLabelImage OutputLabelImageType;
78  typedef typename OutputLabelImageType::PixelType OutputLabelType;
79 
80  typedef TOutputLabelImage OutputImageType;
81  typedef typename OutputImageType::Pointer OutputImagePointerType;
82  typedef typename OutputImageType::PixelType OutputPixelType;
83  typedef typename OutputImageType::RegionType OutputRegionType;
84 
85  typedef TOutputClusteredImage OutputClusteredImageType;
86 
87  itkStaticConstMacro(ImageDimension, unsigned int, InputLabelImageType::ImageDimension);
88 
91  typedef std::set<LabelType> AdjacentLabelsContainerType;
92  typedef std::vector<AdjacentLabelsContainerType> RegionAdjacencyMapType;
93 
94 
96  itkSetMacro(RangeBandwidth, RealType);
97  itkGetMacro(RangeBandwidth, RealType);
99 
101  const OutputLabelImageType* GetLabelOutput() const;
102 
104  OutputLabelImageType* GetLabelOutput();
105 
107  const OutputClusteredImageType* GetClusteredOutput() const;
108 
110  OutputClusteredImageType* GetClusteredOutput();
111 
113  void SetInputLabelImage(const InputLabelImageType* labelImage);
114 
116  void SetInputSpectralImage(const InputSpectralImageType* spectralImage);
117 
119  InputLabelImageType* GetInputLabelImage();
120 
122  InputSpectralImageType* GetInputSpectralImage();
123 
124 protected:
125  void EnlargeOutputRequestedRegion(itk::DataObject* output) override;
126 
127  void GenerateOutputInformation(void) override;
128 
129  void GenerateData() override;
130 
133 
135  ~LabelImageRegionMergingFilter() override;
136 
138  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
139 
141  RegionAdjacencyMapType LabelImageToRegionAdjacencyMap(typename OutputLabelImageType::Pointer inputLabelImage);
142 
143 private:
144  LabelImageRegionMergingFilter(const Self&) = delete;
145  void operator=(const Self&) = delete;
146 
149 
152 
154  std::vector<LabelType> m_CanonicalLabels;
155 
157  std::vector<SpectralPixelType> m_Modes;
158 
160  std::vector<unsigned int> m_PointCounts;
161 };
162 
163 } // end namespace otb
164 
165 #ifndef OTB_MANUAL_INSTANTIATION
167 #endif
168 
169 #endif
otb::LabelImageRegionMergingFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLabelImageRegionMergingFilter.h:51
otb::LabelImageRegionMergingFilter::m_PointCounts
std::vector< unsigned int > m_PointCounts
Definition: otbLabelImageRegionMergingFilter.h:160
otb::LabelImageRegionMergingFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbLabelImageRegionMergingFilter.h:82
otb::LabelImageRegionMergingFilter::m_RangeBandwidth
RealType m_RangeBandwidth
Definition: otbLabelImageRegionMergingFilter.h:148
otb::LabelImageRegionMergingFilter::m_NumberOfComponentsPerPixel
unsigned int m_NumberOfComponentsPerPixel
Definition: otbLabelImageRegionMergingFilter.h:151
otbVectorImage.h
otbImage.h
otb::LabelImageRegionMergingFilter::InputSizeType
InputImageType::SizeType InputSizeType
Definition: otbLabelImageRegionMergingFilter.h:68
otb::LabelImageRegionMergingFilter::OutputRegionType
OutputImageType::RegionType OutputRegionType
Definition: otbLabelImageRegionMergingFilter.h:83
otb::LabelImageRegionMergingFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLabelImageRegionMergingFilter.h:52
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::LabelImageRegionMergingFilter::RegionAdjacencyMapType
std::vector< AdjacentLabelsContainerType > RegionAdjacencyMapType
Definition: otbLabelImageRegionMergingFilter.h:92
otb::LabelImageRegionMergingFilter::Self
LabelImageRegionMergingFilter Self
Definition: otbLabelImageRegionMergingFilter.h:49
otb::LabelImageRegionMergingFilter::InputSpectralImageType
TInputSpectralImage InputSpectralImageType
Definition: otbLabelImageRegionMergingFilter.h:74
otb::LabelImageRegionMergingFilter::OutputImageType
TOutputLabelImage OutputImageType
Definition: otbLabelImageRegionMergingFilter.h:80
otb::LabelImageRegionMergingFilter::PointType
InputImageType::PointType PointType
Definition: otbLabelImageRegionMergingFilter.h:70
otb::LabelImageRegionMergingFilter::RealType
double RealType
Definition: otbLabelImageRegionMergingFilter.h:53
otb::LabelImageRegionMergingFilter::OutputClusteredImageType
TOutputClusteredImage OutputClusteredImageType
Definition: otbLabelImageRegionMergingFilter.h:85
otb::LabelImageRegionMergingFilter::LabelType
InputLabelType LabelType
Definition: otbLabelImageRegionMergingFilter.h:90
otb::LabelImageRegionMergingFilter::InputLabelImageType
TInputLabelImage InputLabelImageType
Definition: otbLabelImageRegionMergingFilter.h:57
otb::LabelImageRegionMergingFilter::InputImagePointerType
InputImageType::Pointer InputImagePointerType
Definition: otbLabelImageRegionMergingFilter.h:65
otb::LabelImageRegionMergingFilter::AdjacentLabelsContainerType
std::set< LabelType > AdjacentLabelsContainerType
Definition: otbLabelImageRegionMergingFilter.h:91
otb::LabelImageRegionMergingFilter::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbLabelImageRegionMergingFilter.h:66
otb::LabelImageRegionMergingFilter::InputLabelType
InputLabelImageType::PixelType InputLabelType
Definition: otbLabelImageRegionMergingFilter.h:62
otb::LabelImageRegionMergingFilter::m_CanonicalLabels
std::vector< LabelType > m_CanonicalLabels
Definition: otbLabelImageRegionMergingFilter.h:154
otb::LabelImageRegionMergingFilter::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbLabelImageRegionMergingFilter.h:81
otb::LabelImageRegionMergingFilter::InputImageType
TInputLabelImage InputImageType
Definition: otbLabelImageRegionMergingFilter.h:64
otb::LabelImageRegionMergingFilter::Superclass
itk::ImageToImageFilter< TInputLabelImage, TOutputLabelImage > Superclass
Definition: otbLabelImageRegionMergingFilter.h:50
otb::LabelImageRegionMergingFilter::m_Modes
std::vector< SpectralPixelType > m_Modes
Definition: otbLabelImageRegionMergingFilter.h:157
otb::LabelImageRegionMergingFilter::SizeType
InputImageType::SizeType SizeType
Definition: otbLabelImageRegionMergingFilter.h:72
otb::LabelImageRegionMergingFilter::InputIndexType
InputImageType::IndexType InputIndexType
Definition: otbLabelImageRegionMergingFilter.h:67
otb::LabelImageRegionMergingFilter::OutputLabelType
OutputLabelImageType::PixelType OutputLabelType
Definition: otbLabelImageRegionMergingFilter.h:78
otb::LabelImageRegionMergingFilter::InputIndexValueType
InputImageType::IndexValueType InputIndexValueType
Definition: otbLabelImageRegionMergingFilter.h:69
otbLabelImageRegionMergingFilter.hxx
otb::LabelImageRegionMergingFilter
Definition: otbLabelImageRegionMergingFilter.h:45
otb::LabelImageRegionMergingFilter::RegionType
InputImageType::RegionType RegionType
Definition: otbLabelImageRegionMergingFilter.h:71
otb::LabelImageRegionMergingFilter::OutputLabelImageType
TOutputLabelImage OutputLabelImageType
Definition: otbLabelImageRegionMergingFilter.h:77
otb::LabelImageRegionMergingFilter::SpectralPixelType
TInputSpectralImage::PixelType SpectralPixelType
Definition: otbLabelImageRegionMergingFilter.h:75