OTB  9.0.0
Orfeo Toolbox
otbLabelImageRegionPruningFilter.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 otbLabelImageRegionPruningFilter_h
22 #define otbLabelImageRegionPruningFilter_h
23 
24 #include "otbImage.h"
25 #include "otbVectorImage.h"
26 #include "itkImageToImageFilter.h"
27 #include "itkNumericTraits.h"
28 
29 #include <set>
30 
31 namespace otb
32 {
33 
45 template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage = TInputLabelImage, class TOutputClusteredImage = TInputSpectralImage>
46 class ITK_EXPORT LabelImageRegionPruningFilter : public itk::ImageToImageFilter<TInputLabelImage, TOutputLabelImage>
47 {
48 public:
51  typedef itk::ImageToImageFilter<TInputLabelImage, TOutputLabelImage> Superclass;
52  typedef itk::SmartPointer<Self> Pointer;
53  typedef itk::SmartPointer<const Self> ConstPointer;
54  typedef double RealType;
55 
57  itkTypeMacro(LabelImageRegionPruningFilter, ImageToImageFilter);
58  itkNewMacro(Self);
60 
62  typedef TInputLabelImage InputLabelImageType;
63  typedef typename InputLabelImageType::PixelType InputLabelType;
64 
65  typedef TInputLabelImage InputImageType;
66  typedef typename InputImageType::Pointer InputImagePointerType;
67  typedef typename InputImageType::PixelType InputPixelType;
68  typedef typename InputImageType::IndexType InputIndexType;
69  typedef typename InputImageType::SizeType InputSizeType;
70  typedef typename InputImageType::IndexValueType InputIndexValueType;
71  typedef typename InputImageType::PointType PointType;
72  typedef typename InputImageType::RegionType RegionType;
73  typedef typename InputImageType::SizeType SizeType;
74 
75  typedef TInputSpectralImage InputSpectralImageType;
76  typedef typename TInputSpectralImage::PixelType SpectralPixelType;
77 
78  typedef TOutputLabelImage OutputLabelImageType;
79  typedef typename OutputLabelImageType::PixelType OutputLabelType;
80 
81  typedef TOutputLabelImage OutputImageType;
82  typedef typename OutputImageType::Pointer OutputImagePointerType;
83  typedef typename OutputImageType::PixelType OutputPixelType;
84  typedef typename OutputImageType::RegionType OutputRegionType;
85 
86  typedef TOutputClusteredImage OutputClusteredImageType;
87 
88  itkStaticConstMacro(ImageDimension, unsigned int, InputLabelImageType::ImageDimension);
89 
92  typedef std::set<LabelType> AdjacentLabelsContainerType;
93  typedef std::vector<AdjacentLabelsContainerType> RegionAdjacencyMapType;
94 
95  itkSetMacro(MinRegionSize, RealType);
96  itkGetConstMacro(MinRegionSize, RealType);
97 
99  const OutputLabelImageType* GetLabelOutput() const;
100 
102  OutputLabelImageType* GetLabelOutput();
103 
105  const OutputClusteredImageType* GetClusteredOutput() const;
106 
108  OutputClusteredImageType* GetClusteredOutput();
109 
111  void SetInputLabelImage(const InputLabelImageType* labelImage);
112 
114  void SetInputSpectralImage(const InputSpectralImageType* spectralImage);
115 
117  InputLabelImageType* GetInputLabelImage();
118 
120  InputSpectralImageType* GetInputSpectralImage();
121 
122 protected:
123  void EnlargeOutputRequestedRegion(itk::DataObject* output) override;
124 
125  void GenerateOutputInformation(void) override;
126 
127  void GenerateData() override;
128 
131 
133  ~LabelImageRegionPruningFilter() override;
134 
136  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
137 
139  RegionAdjacencyMapType LabelImageToRegionAdjacencyMap(typename OutputLabelImageType::Pointer inputLabelImage);
140 
141 private:
142  LabelImageRegionPruningFilter(const Self&) = delete;
143  void operator=(const Self&) = delete;
144 
147  unsigned int m_MinRegionSize;
148 
150  std::vector<LabelType> m_CanonicalLabels;
151 
153  std::vector<SpectralPixelType> m_Modes;
154 
156  std::vector<unsigned int> m_PointCounts;
157 };
158 
159 } // end namespace otb
160 
161 #ifndef OTB_MANUAL_INSTANTIATION
163 #endif
164 
165 #endif
otb::LabelImageRegionPruningFilter::m_Modes
std::vector< SpectralPixelType > m_Modes
Definition: otbLabelImageRegionPruningFilter.h:153
otb::LabelImageRegionPruningFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLabelImageRegionPruningFilter.h:52
otb::LabelImageRegionPruningFilter::PointType
InputImageType::PointType PointType
Definition: otbLabelImageRegionPruningFilter.h:71
otbLabelImageRegionPruningFilter.hxx
otbVectorImage.h
otbImage.h
otb::LabelImageRegionPruningFilter::m_PointCounts
std::vector< unsigned int > m_PointCounts
Definition: otbLabelImageRegionPruningFilter.h:156
otb::LabelImageRegionPruningFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLabelImageRegionPruningFilter.h:53
otb::LabelImageRegionPruningFilter::OutputRegionType
OutputImageType::RegionType OutputRegionType
Definition: otbLabelImageRegionPruningFilter.h:84
otb::LabelImageRegionPruningFilter::InputIndexType
InputImageType::IndexType InputIndexType
Definition: otbLabelImageRegionPruningFilter.h:68
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::LabelImageRegionPruningFilter::InputIndexValueType
InputImageType::IndexValueType InputIndexValueType
Definition: otbLabelImageRegionPruningFilter.h:70
otb::LabelImageRegionPruningFilter::m_NumberOfComponentsPerPixel
unsigned int m_NumberOfComponentsPerPixel
Definition: otbLabelImageRegionPruningFilter.h:146
otb::LabelImageRegionPruningFilter::RegionAdjacencyMapType
std::vector< AdjacentLabelsContainerType > RegionAdjacencyMapType
Definition: otbLabelImageRegionPruningFilter.h:93
otb::LabelImageRegionPruningFilter::OutputClusteredImageType
TOutputClusteredImage OutputClusteredImageType
Definition: otbLabelImageRegionPruningFilter.h:86
otb::LabelImageRegionPruningFilter::InputSizeType
InputImageType::SizeType InputSizeType
Definition: otbLabelImageRegionPruningFilter.h:69
otb::LabelImageRegionPruningFilter::LabelType
InputLabelType LabelType
Definition: otbLabelImageRegionPruningFilter.h:91
otb::LabelImageRegionPruningFilter::InputLabelImageType
TInputLabelImage InputLabelImageType
Definition: otbLabelImageRegionPruningFilter.h:58
otb::LabelImageRegionPruningFilter::OutputImageType
TOutputLabelImage OutputImageType
Definition: otbLabelImageRegionPruningFilter.h:81
otb::LabelImageRegionPruningFilter::RegionType
InputImageType::RegionType RegionType
Definition: otbLabelImageRegionPruningFilter.h:72
otb::LabelImageRegionPruningFilter::SizeType
InputImageType::SizeType SizeType
Definition: otbLabelImageRegionPruningFilter.h:73
otb::LabelImageRegionPruningFilter
Definition: otbLabelImageRegionPruningFilter.h:46
otb::LabelImageRegionPruningFilter::InputLabelType
InputLabelImageType::PixelType InputLabelType
Definition: otbLabelImageRegionPruningFilter.h:63
otb::LabelImageRegionPruningFilter::InputImageType
TInputLabelImage InputImageType
Definition: otbLabelImageRegionPruningFilter.h:65
otb::LabelImageRegionPruningFilter::Superclass
itk::ImageToImageFilter< TInputLabelImage, TOutputLabelImage > Superclass
Definition: otbLabelImageRegionPruningFilter.h:51
otb::LabelImageRegionPruningFilter::OutputLabelType
OutputLabelImageType::PixelType OutputLabelType
Definition: otbLabelImageRegionPruningFilter.h:79
otb::LabelImageRegionPruningFilter::SpectralPixelType
TInputSpectralImage::PixelType SpectralPixelType
Definition: otbLabelImageRegionPruningFilter.h:76
otb::LabelImageRegionPruningFilter::m_CanonicalLabels
std::vector< LabelType > m_CanonicalLabels
Definition: otbLabelImageRegionPruningFilter.h:150
otb::LabelImageRegionPruningFilter::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbLabelImageRegionPruningFilter.h:82
otb::LabelImageRegionPruningFilter::Self
LabelImageRegionPruningFilter Self
Definition: otbLabelImageRegionPruningFilter.h:50
otb::LabelImageRegionPruningFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbLabelImageRegionPruningFilter.h:83
otb::LabelImageRegionPruningFilter::RealType
double RealType
Definition: otbLabelImageRegionPruningFilter.h:54
otb::LabelImageRegionPruningFilter::AdjacentLabelsContainerType
std::set< LabelType > AdjacentLabelsContainerType
Definition: otbLabelImageRegionPruningFilter.h:92
otb::LabelImageRegionPruningFilter::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbLabelImageRegionPruningFilter.h:67
otb::LabelImageRegionPruningFilter::m_MinRegionSize
unsigned int m_MinRegionSize
Definition: otbLabelImageRegionPruningFilter.h:147
otb::LabelImageRegionPruningFilter::OutputLabelImageType
TOutputLabelImage OutputLabelImageType
Definition: otbLabelImageRegionPruningFilter.h:78
otb::LabelImageRegionPruningFilter::InputImagePointerType
InputImageType::Pointer InputImagePointerType
Definition: otbLabelImageRegionPruningFilter.h:66
otb::LabelImageRegionPruningFilter::InputSpectralImageType
TInputSpectralImage InputSpectralImageType
Definition: otbLabelImageRegionPruningFilter.h:75