OTB  6.7.0
Orfeo Toolbox
otbLabelToBoundaryImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbLabelToBoundaryImageFilter_h
23 #define otbLabelToBoundaryImageFilter_h
24 
26 
27 namespace otb
28 {
29 namespace Functor
30 {
31 
43 template < class TInput, class TOutput >
45 {
46 public:
50 
51  TOutput operator() ( const TInput & input )
52  {
53  unsigned char output = 1;
54  if (input.GetCenterPixel() == input.GetPixel(5) &&
55  input.GetCenterPixel() == input.GetPixel(7) &&
56  input.GetCenterPixel() == input.GetPixel(8))
57  {
58  output = 0;
59  }
60  return static_cast<TOutput>(output);
61  }
62 }; // end of class
63 
64 } // end of Functor namespace
65 
77 template < class TInputImage, class TOutputImage >
79  : public UnaryFunctorNeighborhoodImageFilter< TInputImage, TOutputImage,
80  Functor::LabelToBoundaryFunctor<
81  typename itk::ConstNeighborhoodIterator<TInputImage>,
82  typename TOutputImage::PixelType > >
83 {
84 public:
86  typedef UnaryFunctorNeighborhoodImageFilter< TInputImage, TOutputImage,
89  typename TOutputImage::PixelType > > Superclass;
92 
93  itkNewMacro(Self);
94 
96 
97 protected:
99  {
100  this->SetRadius(1);
101  }
103 
104 private:
105  LabelToBoundaryImageFilter( const Self & ); // Not implemented
106  void operator=( const Self & ); // Not implemented
107 }; // end of class
108 
109 } // end of otb namespace
110 
111 #endif
Implements neighborhood-wise generic operation on image.
itk::SmartPointer< const Self > ConstPointer
UnaryFunctorNeighborhoodImageFilter< TInputImage, TOutputImage, Functor::LabelToBoundaryFunctor< typename itk::ConstNeighborhoodIterator< TInputImage >, typename TOutputImage::PixelType > > Superclass
Filter to extract boundaries of a label image.
Functor to extract segmentation boundaries.