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 __itkAttributeUniqueLabelMapFilter_h 00019 #define __itkAttributeUniqueLabelMapFilter_h 00020 00021 #include "itkInPlaceLabelMapFilter.h" 00022 #include "itkAttributeLabelObject.h" 00023 00024 namespace itk { 00045 template<class TImage, class TAttributeAccessor= 00046 typename Functor::AttributeLabelObjectAccessor< typename TImage::LabelObjectType > > 00047 class ITK_EXPORT AttributeUniqueLabelMapFilter : 00048 public InPlaceLabelMapFilter<TImage> 00049 { 00050 public: 00052 typedef AttributeUniqueLabelMapFilter Self; 00053 typedef InPlaceLabelMapFilter<TImage> Superclass; 00054 typedef SmartPointer<Self> Pointer; 00055 typedef SmartPointer<const Self> ConstPointer; 00056 00058 typedef TImage ImageType; 00059 typedef typename ImageType::Pointer ImagePointer; 00060 typedef typename ImageType::ConstPointer ImageConstPointer; 00061 typedef typename ImageType::PixelType PixelType; 00062 typedef typename ImageType::IndexType IndexType; 00063 typedef typename ImageType::LabelObjectType LabelObjectType; 00064 00065 typedef TAttributeAccessor AttributeAccessorType; 00066 typedef typename AttributeAccessorType::AttributeValueType AttributeValueType; 00067 00068 typedef typename LabelObjectType::LineType LineType; 00069 00071 itkStaticConstMacro(ImageDimension, unsigned int, 00072 TImage::ImageDimension); 00073 00075 itkNewMacro(Self); 00076 00078 itkTypeMacro(AttributeUniqueLabelMapFilter, 00079 InPlaceLabelMapFilter); 00080 00081 #ifdef ITK_USE_CONCEPT_CHECKING 00082 00083 /* itkConceptMacro(InputEqualityComparableCheck, 00084 (Concept::EqualityComparable<InputImagePixelType>)); 00085 itkConceptMacro(IntConvertibleToInputCheck, 00086 (Concept::Convertible<int, InputImagePixelType>)); 00087 itkConceptMacro(InputOStreamWritableCheck, 00088 (Concept::OStreamWritable<InputImagePixelType>));*/ 00089 00091 #endif 00092 00098 itkSetMacro( ReverseOrdering, bool ); 00099 itkGetConstReferenceMacro( ReverseOrdering, bool ); 00100 itkBooleanMacro( ReverseOrdering ); 00102 00103 protected: 00104 AttributeUniqueLabelMapFilter(); 00105 ~AttributeUniqueLabelMapFilter() {}; 00106 00107 void GenerateData(); 00108 00109 void PrintSelf(std::ostream& os, Indent indent) const; 00110 00111 bool m_ReverseOrdering; 00112 00113 private: 00114 AttributeUniqueLabelMapFilter(const Self&); //purposely not implemented 00115 void operator=(const Self&); //purposely not implemented 00116 00117 struct LineOfLabelObject 00118 { 00119 typedef typename LabelObjectType::LineType LineType; 00120 00121 LineOfLabelObject( const LineType l, LabelObjectType * lo ) 00122 { 00123 this->line = l; 00124 this->labelObject = lo; 00125 } 00126 LineType line; 00127 LabelObjectType * labelObject; 00128 }; 00129 00130 class LineOfLabelObjectComparator 00131 { 00132 public: 00133 bool operator()( const LineOfLabelObject & lla, const LineOfLabelObject & llb ) 00134 { 00135 for( int i=ImageDimension-1; i>=0; i-- ) 00136 { 00137 if( lla.line.GetIndex()[i] > llb.line.GetIndex()[i] ) 00138 { 00139 return true; 00140 } 00141 else if( lla.line.GetIndex()[i] < llb.line.GetIndex()[i] ) 00142 { 00143 return false; 00144 } 00145 } 00146 return false; 00147 } 00148 }; 00149 00150 }; // end of class 00151 00152 } // end namespace itk 00153 00154 #ifndef ITK_MANUAL_INSTANTIATION 00155 #include "itkAttributeUniqueLabelMapFilter.hxx" 00156 #endif 00157 00158 #endif 00159