ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAnchorErodeDilateLine.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkAnchorErodeDilateLine_h
19 #define itkAnchorErodeDilateLine_h
20 
22 
23 namespace itk
24 {
36 template< typename TInputPix, typename TCompare >
37 class ITK_TEMPLATE_EXPORT AnchorErodeDilateLine
38 {
39 public:
40 
42  using InputImagePixelType = TInputPix;
43 
44  void DoLine(std::vector<TInputPix> & buffer, std::vector<TInputPix> & inbuffer,
45  unsigned bufflength);
46 
47  void SetSize(unsigned int size)
48  {
49  m_Size = size;
50  }
51 
52  void PrintSelf(std::ostream & os, Indent indent) const;
53 
55  ~AnchorErodeDilateLine() = default;
56 
57 private:
58  unsigned int m_Size;
59 
61 
62  bool StartLine(std::vector<TInputPix> & buffer,
63  std::vector<TInputPix> & inbuffer,
64  InputImagePixelType & Extreme,
65  int & outLeftP,
66  int & outRightP,
67  int & inLeftP,
68  int & inRightP,
69  int middle);
70 
71  void FinishLine(std::vector<TInputPix> & buffer,
72  std::vector<TInputPix> & inbuffer,
73  InputImagePixelType & Extreme,
74  int & outLeftP,
75  int & outRightP,
76  int & inLeftP,
77  int & inRightP,
78  int middle);
79 
81  {
82  // bool, short and char are acceptable for vector based algorithm: they do
83  // not require
84  // too much memory. Other types are not usable with that algorithm
85  return typeid( InputImagePixelType ) == typeid( unsigned char )
86  || typeid( InputImagePixelType ) == typeid( signed char )
87  || typeid( InputImagePixelType ) == typeid( unsigned short )
88  || typeid( InputImagePixelType ) == typeid( signed short )
89  || typeid( InputImagePixelType ) == typeid( bool );
90  }
91 
92  inline bool StrictCompare( const InputImagePixelType & a, const InputImagePixelType & b )
93  {
94  TCompare compare;
95  return compare( a, b );
96  }
97 
98  inline bool Compare( const InputImagePixelType & a, const InputImagePixelType & b )
99  {
100  TCompare compare;
101  return compare( a, b ) || Math::AlmostEquals(a, b);
102  }
103 
104 }; // end of class
105 } // end namespace itk
106 
107 #ifndef ITK_MANUAL_INSTANTIATION
108 #include "itkAnchorErodeDilateLine.hxx"
109 #endif
110 
111 #endif
void DoLine(LineBufferType &LineBuf, LineBufferType &tmpLineBuf, const RealType magnitude, const RealType m_Extreme)
bool Compare(const InputImagePixelType &a, const InputImagePixelType &b)
bool StrictCompare(const InputImagePixelType &a, const InputImagePixelType &b)
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types...
Definition: itkMath.h:669
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SetSize(unsigned int size)
class to implement erosions and dilations using anchor methods. This is the base class that must be i...