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
23namespace itk
24{
36template <typename TInputPix, typename TCompare>
37class ITK_TEMPLATE_EXPORT AnchorErodeDilateLine
38{
39public:
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
58
59private:
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
class to implement erosions and dilations using anchor methods. This is the base class that must be i...
void DoLine(std::vector< TInputPix > &buffer, std::vector< TInputPix > &inbuffer, unsigned int bufflength)
bool StrictCompare(const InputImagePixelType &a, const InputImagePixelType &b)
bool StartLine(std::vector< TInputPix > &buffer, std::vector< TInputPix > &inbuffer, InputImagePixelType &Extreme, int &outLeftP, int &outRightP, int &inLeftP, int &inRightP, int middle)
void SetSize(unsigned int size)
void FinishLine(std::vector< TInputPix > &buffer, std::vector< TInputPix > &inbuffer, InputImagePixelType &Extreme, int &outLeftP, int &outRightP, int &inLeftP, int &inRightP, int middle)
bool Compare(const InputImagePixelType &a, const InputImagePixelType &b)
void PrintSelf(std::ostream &os, Indent indent) const
Control indentation during Print() invocation.
Definition: itkIndent.h:50
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types.
Definition: itkMath.h:684
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....