OTB  10.0.0
Orfeo Toolbox
otbLabelImageRegionMergingFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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:
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
TInputSpectralImage::PixelType SpectralPixelType
std::vector< AdjacentLabelsContainerType > RegionAdjacencyMapType
LabelImageRegionMergingFilter(const Self &)=delete
itk::ImageToImageFilter< TInputLabelImage, TOutputLabelImage > Superclass
InputImageType::IndexValueType InputIndexValueType
OutputLabelImageType::PixelType OutputLabelType
void operator=(const Self &)=delete
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.