ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkAnchorOpenCloseLine.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 __itkAnchorOpenCloseLine_h
19 #define __itkAnchorOpenCloseLine_h
20 
21 #include "itkMorphologyHistogram.h"
22 #include "itkIndent.h"
23 
24 //#define RAWHIST
25 
26 namespace itk
27 {
35 template< class TInputPix, class TCompare >
36 class ITK_EXPORT AnchorOpenCloseLine
37 {
38 public:
39 
41  typedef TInputPix InputImagePixelType;
44  {
45  }
47 
48  void PrintSelf(std::ostream & os, Indent indent) const;
49 
52  void DoLine(std::vector<InputImagePixelType> & buffer, unsigned bufflength);
53 
54  void SetSize(unsigned int size)
55  {
56  m_Size = size;
57  }
58 
59 private:
60  unsigned int m_Size;
61 
63 
64  bool StartLine(std::vector<InputImagePixelType> & buffer,
65  InputImagePixelType & Extreme,
66  unsigned & outLeftP,
67  unsigned & outRightP);
68 
69  void FinishLine(std::vector<InputImagePixelType> & buffer,
70  InputImagePixelType & Extreme,
71  unsigned & outLeftP,
72  unsigned & outRightP);
73 
74  inline bool Compare1( const InputImagePixelType & a, const InputImagePixelType & b )
75  {
76  TCompare compare;
77  return ! compare( a, b );
78  }
79 
80  inline bool Compare2( const InputImagePixelType & a, const InputImagePixelType & b )
81  {
82  TCompare compare;
83  return compare( a, b ) || a == b;
84  }
85 
86 }; // end of class
87 } // end namespace itk
88 
89 #ifndef ITK_MANUAL_INSTANTIATION
90 #include "itkAnchorOpenCloseLine.hxx"
91 #endif
92 
93 #endif
94