ITK  6.0.0
Insight Toolkit
itkAnchorErodeDilateLine.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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
45  DoLine(std::vector<TInputPix> & buffer, std::vector<TInputPix> & inbuffer, unsigned int bufflength);
46 
47  void
48  SetSize(unsigned int size)
49  {
50  m_Size = size;
51  }
52 
53  void
54  PrintSelf(std::ostream & os, Indent indent) const;
55 
57  ~AnchorErodeDilateLine() = default;
58 
59 private:
60  unsigned int m_Size;
61 
63 
64  bool
65  StartLine(std::vector<TInputPix> & buffer,
66  std::vector<TInputPix> & inbuffer,
67  InputImagePixelType & Extreme,
68  int & outLeftP,
69  int & outRightP,
70  int & inLeftP,
71  int & inRightP,
72  int middle);
73 
74  void
75  FinishLine(std::vector<TInputPix> & buffer,
76  std::vector<TInputPix> & inbuffer,
77  InputImagePixelType & Extreme,
78  int & outLeftP,
79  int & outRightP,
80  int & inLeftP,
81  int & inRightP,
82  int middle);
83 
84  bool
86  {
87  // bool, short and char are acceptable for vector based algorithm: they do
88  // not require
89  // too much memory. Other types are not usable with that algorithm
90  return typeid(InputImagePixelType) == typeid(unsigned char) || typeid(InputImagePixelType) == typeid(signed char) ||
91  typeid(InputImagePixelType) == typeid(unsigned short) || typeid(InputImagePixelType) == typeid(short) ||
92  typeid(InputImagePixelType) == typeid(bool);
93  }
94 
95  inline bool
97  {
98  TCompare compare;
99  return compare(a, b);
100  }
101 
102  inline bool
104  {
105  TCompare compare;
106  return compare(a, b) || Math::AlmostEquals(a, b);
107  }
108 
109 }; // end of class
110 } // end namespace itk
111 
112 #ifndef ITK_MANUAL_INSTANTIATION
113 # include "itkAnchorErodeDilateLine.hxx"
114 #endif
115 
116 #endif
itk::AnchorErodeDilateLine::Compare
bool Compare(const InputImagePixelType &a, const InputImagePixelType &b)
Definition: itkAnchorErodeDilateLine.h:103
itk::AnchorErodeDilateLine::m_Size
unsigned int m_Size
Definition: itkAnchorErodeDilateLine.h:60
itk::AnchorErodeDilateLine::StrictCompare
bool StrictCompare(const InputImagePixelType &a, const InputImagePixelType &b)
Definition: itkAnchorErodeDilateLine.h:96
itk::AnchorErodeDilateLine::InputImagePixelType
TInputPix InputImagePixelType
Definition: itkAnchorErodeDilateLine.h:42
itk::Function::MorphologyHistogram
Definition: itkMorphologyHistogram.h:31
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::AnchorErodeDilateLine::SetSize
void SetSize(unsigned int size)
Definition: itkAnchorErodeDilateLine.h:48
itkMovingHistogramMorphologyImageFilter.h
itk::AnchorErodeDilateLine
class to implement erosions and dilations using anchor methods. This is the base class that must be i...
Definition: itkAnchorErodeDilateLine.h:37
itk::AnchorErodeDilateLine::UseVectorBasedHistogram
bool UseVectorBasedHistogram()
Definition: itkAnchorErodeDilateLine.h:85
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Math::AlmostEquals
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types.
Definition: itkMath.h:684