OTB  6.7.0
Orfeo Toolbox
otbDisparityMapMedianFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 otbDisparityMapMedianFilter_h
22 #define otbDisparityMapMedianFilter_h
23 
24 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
25 #include "itkOptMedianImageFilter.h"
26 #else
27 
28 #include "itkImageToImageFilter.h"
29 #include "otbImage.h"
30 
31 namespace otb
32 {
72 template <class TInputImage, class TOutputImage, class TMask>
73 class ITK_EXPORT DisparityMapMedianFilter :
74  public itk::ImageToImageFilter< TInputImage, TOutputImage>
75 {
76 public:
78  itkStaticConstMacro(InputImageDimension, unsigned int,
79  TInputImage::ImageDimension);
80  itkStaticConstMacro(OutputImageDimension, unsigned int,
81  TOutputImage::ImageDimension);
83 
85  typedef TInputImage InputImageType;
86  typedef TOutputImage OutputImageType;
87  typedef TMask MaskImageType;
88 
89 
95 
97  itkNewMacro(Self);
98 
100  itkTypeMacro(DisparityMapMedianFilter, ImageToImageFilter);
101 
103  typedef typename InputImageType::PixelType InputPixelType;
104  typedef typename OutputImageType::PixelType OutputPixelType;
105  typedef typename MaskImageType::PixelType MaskImagePixelType;
106  typedef typename MaskImageType::Pointer MaskImagePointerType;
107 
108  typedef typename InputImageType::RegionType InputImageRegionType;
109  typedef typename OutputImageType::RegionType OutputImageRegionType;
111  typedef typename OutputImageType::IndexValueType IndexValueType;
112 
114  void SetMaskInput( const TMask * inputmask); // mask corresponding to the subpixel disparity map
115 
117  const TMask * GetMaskInput();
118 
120  TMask * GetOutputMask(); // mask corresponding to the median disparity map
121 
123  TOutputImage * GetOutputDisparityMap(); // input disparity map updated (incoherences between median and input disparity map are removed)
124 
126  TMask * GetOutputDisparityMask();
127 
129  itkSetMacro(Radius, SizeType);
130  itkGetMacro(Radius, SizeType);
132 
134  void SetRadius(unsigned int radius)
135  {
136  m_Radius.Fill(radius);
137  }
138 
140  itkSetMacro(IncoherenceThreshold, double);
141  itkGetMacro(IncoherenceThreshold, double);
143 
144 #ifdef ITK_USE_CONCEPT_CHECKING
145 
146  itkConceptMacro(SameDimensionCheck,
148  itkConceptMacro(InputConvertibleToOutputCheck,
150  itkConceptMacro(InputLessThanComparableCheck,
152 
154 #endif
155 
156 protected:
159  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
160 
167  void GenerateInputRequestedRegion() throw(itk::InvalidRequestedRegionError) override;
168 
170  void GenerateOutputInformation(void) override;
171 
173  void GenerateData() override;
174 
175 private:
176  DisparityMapMedianFilter(const Self&) = delete;
177  void operator=(const Self&) = delete;
178 
180  SizeType m_Radius;
181 
183  double m_IncoherenceThreshold;
184 };
185 
186 } // end namespace otb
187 
188 #ifndef OTB_MANUAL_INSTANTIATION
190 #endif
191 
192 #endif
193 
194 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
InputImageType::PixelType InputPixelType
itk::SmartPointer< const Self > ConstPointer
InputImageType::RegionType InputImageRegionType
Applies a median filter to a monoband disparity map with an associated mask.
MaskImageType::PixelType MaskImagePixelType
OutputImageType::RegionType OutputImageRegionType
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
OutputImageType::IndexValueType IndexValueType
OutputImageType::PixelType OutputPixelType
#define itkConceptMacro(name, concept)