OTB  10.0.0
Orfeo Toolbox
otbMeanShiftConnectedComponentSegmentationFilter.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 otbMeanShiftConnectedComponentSegmentationFilter_h
22 #define otbMeanShiftConnectedComponentSegmentationFilter_h
23 
24 #include "itkMacro.h"
25 
27 #include "itkConnectedComponentFunctorImageFilter.h"
28 #include "otbMaskMuParserFilter.h"
29 #include "itkRelabelComponentImageFilter.h"
30 
32 #include <string>
33 
34 namespace otb
35 {
36 
58 template <class TVInputImage, class TMaskImage, class TLabelImage>
59 class MeanShiftConnectedComponentSegmentationFilter : public itk::ImageToImageFilter<TVInputImage, TLabelImage>
60 {
61 public:
65  typedef itk::ImageToImageFilter<TVInputImage, TLabelImage> Superclass;
66 
67  typedef itk::SmartPointer<Self> Pointer;
68  typedef itk::SmartPointer<const Self> ConstPointer;
69 
70  typedef unsigned int ObjectSizeType;
71 
73  typedef TVInputImage VectorImageType;
74  typedef TMaskImage MaskImageType;
75  typedef TLabelImage LabelImageType;
76 
77  typedef typename VectorImageType::Pointer VectorImagePointerType;
78  typedef typename VectorImageType::PixelType VectorImagePixelType;
79 
81  itkNewMacro(Self);
82 
84  itkTypeMacro(MeanShiftConnectedComponentSegmentationFilter, ImageToImageFilter);
85 
87  itkStaticConstMacro(InputImageDimension, unsigned int, TVInputImage::ImageDimension);
88 
89  // Mask generation
91  typedef itk::ConnectedComponentFunctorImageFilter<VectorImageType, LabelImageType, FunctorType, MaskImageType> ConnectedComponentFilterType;
92 
93  // mask typedef
95 
96  // Labelization
97  typedef itk::RelabelComponentImageFilter<LabelImageType, LabelImageType> RelabelComponentFilterType;
98 
99  typedef double KernelType;
101 
103 
104  // ** // meanshift filter
105  /* Set/Get mean shift filter */
106  itkSetObjectMacro(MeanShiftFilter, MeanShiftFilterType);
108 
109  /* Set the mathematical expression used for the mask */
110  itkSetStringMacro(MaskExpression);
111 
112  /* Get the mathematical expression used for the mask */
113  itkGetStringMacro(MaskExpression);
114 
115  /* Set the mathematical expression used during connected component segmentation */
116  itkSetStringMacro(ConnectedComponentExpression);
117 
118  /* Get the mathematical expression used during connected component segmentation */
119  itkGetStringMacro(ConnectedComponentExpression);
120 
121  /* Set the minimum object size */
122  itkSetMacro(MinimumObjectSize, ObjectSizeType);
123 
124  /* Get the minimum object size */
125  itkGetMacro(MinimumObjectSize, ObjectSizeType);
126 
127 protected:
129 
131 
132  void GenerateInputRequestedRegion() override;
133  void GenerateData() override;
134 
135 private:
137 
138  /* CC parameters */
140  std::string m_MaskExpression;
142  /* */
143 };
144 
145 
146 } // end namespace itk
147 
148 #ifndef OTB_MANUAL_INSTANTIATION
150 #endif
151 
152 #endif
[internal] Helper class to perform connected component segmentation on an input image,
itkGetObjectMacro(MeanShiftFilter, MeanShiftFilterType)
otb::MeanShiftSmoothingImageFilter< VectorImageType, VectorImageType > MeanShiftFilterType
itk::ConnectedComponentFunctorImageFilter< VectorImageType, LabelImageType, FunctorType, MaskImageType > ConnectedComponentFilterType
Functor::ConnectedComponentMuParserFunctor< VectorImagePixelType > FunctorType
itk::RelabelComponentImageFilter< LabelImageType, LabelImageType > RelabelComponentFilterType
otb::MaskMuParserFilter< VectorImageType, MaskImageType > MaskMuParserFilterType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.