ITK  4.4.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< class TInputPix, class TCompare >
37 class ITK_EXPORT AnchorErodeDilateLine
38 {
39 public:
40 
42  typedef TInputPix InputImagePixelType;
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 
56  {
57  }
58 
59 private:
60  unsigned int m_Size;
61 
63 
64  bool StartLine(std::vector<TInputPix> & buffer,
65  std::vector<TInputPix> & inbuffer,
66  InputImagePixelType & Extreme,
67  int & outLeftP,
68  int & outRightP,
69  int & inLeftP,
70  int & inRightP,
71  int middle);
72 
73  void FinishLine(std::vector<TInputPix> & buffer,
74  std::vector<TInputPix> & inbuffer,
75  InputImagePixelType & Extreme,
76  int & outLeftP,
77  int & outRightP,
78  int & inLeftP,
79  int & inRightP,
80  int middle);
81 
82  bool UseVectorBasedHistogram()
83  {
84  // bool, short and char are acceptable for vector based algorithm: they do
85  // not require
86  // too much memory. Other types are not usable with that algorithm
87  return typeid( InputImagePixelType ) == typeid( unsigned char )
88  || typeid( InputImagePixelType ) == typeid( signed char )
89  || typeid( InputImagePixelType ) == typeid( unsigned short )
90  || typeid( InputImagePixelType ) == typeid( signed short )
91  || typeid( InputImagePixelType ) == typeid( bool );
92  }
93 
94  inline bool StrictCompare( const InputImagePixelType & a, const InputImagePixelType & b )
95  {
96  TCompare compare;
97  return compare( a, b );
98  }
99 
100  inline bool Compare( const InputImagePixelType & a, const InputImagePixelType & b )
101  {
102  TCompare compare;
103  return compare( a, b ) || a == b;
104  }
105 
106 }; // end of class
107 } // end namespace itk
108 
109 #ifndef ITK_MANUAL_INSTANTIATION
110 #include "itkAnchorErodeDilateLine.hxx"
111 #endif
112 
113 #endif
114