ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkAnchorOpenCloseLine_h 00019 #define __itkAnchorOpenCloseLine_h 00020 00021 #include "itkMorphologyHistogram.h" 00022 #include "itkIndent.h" 00023 00024 //#define RAWHIST 00025 00026 namespace itk 00027 { 00035 template< class TInputPix, class TCompare > 00036 class ITK_EXPORT AnchorOpenCloseLine 00037 { 00038 public: 00039 00041 typedef TInputPix InputImagePixelType; 00042 AnchorOpenCloseLine(); 00043 ~AnchorOpenCloseLine() 00044 { 00045 } 00047 00048 void PrintSelf(std::ostream & os, Indent indent) const; 00049 00052 void DoLine(std::vector<InputImagePixelType> & buffer, unsigned bufflength); 00053 00054 void SetSize(unsigned int size) 00055 { 00056 m_Size = size; 00057 } 00058 00059 private: 00060 unsigned int m_Size; 00061 00062 typedef Function::MorphologyHistogram< InputImagePixelType, TCompare > HistogramType; 00063 00064 bool StartLine(std::vector<InputImagePixelType> & buffer, 00065 InputImagePixelType & Extreme, 00066 unsigned & outLeftP, 00067 unsigned & outRightP); 00068 00069 void FinishLine(std::vector<InputImagePixelType> & buffer, 00070 InputImagePixelType & Extreme, 00071 unsigned & outLeftP, 00072 unsigned & outRightP); 00073 00074 inline bool Compare1( const InputImagePixelType & a, const InputImagePixelType & b ) 00075 { 00076 TCompare compare; 00077 return ! compare( a, b ); 00078 } 00079 00080 inline bool Compare2( const InputImagePixelType & a, const InputImagePixelType & b ) 00081 { 00082 TCompare compare; 00083 return compare( a, b ) || a == b; 00084 } 00085 00086 }; // end of class 00087 } // end namespace itk 00088 00089 #ifndef ITK_MANUAL_INSTANTIATION 00090 #include "itkAnchorOpenCloseLine.hxx" 00091 #endif 00092 00093 #endif 00094