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 00019 #ifndef __itkWhitakerSparseLevelSetImage_h 00020 #define __itkWhitakerSparseLevelSetImage_h 00021 00022 #include "itkLevelSetSparseImageBase.h" 00023 #include "itkLabelObject.h" 00024 #include "itkLabelMap.h" 00025 00026 namespace itk 00027 { 00040 template< typename TOutput, unsigned int VDimension > 00041 class WhitakerSparseLevelSetImage : 00042 public LevelSetSparseImageBase< TOutput, VDimension > 00043 { 00044 public: 00045 typedef WhitakerSparseLevelSetImage Self; 00046 typedef SmartPointer< Self > Pointer; 00047 typedef SmartPointer< const Self > ConstPointer; 00048 typedef LevelSetSparseImageBase< TOutput, VDimension > Superclass; 00049 00051 itkNewMacro(Self); 00052 00054 itkTypeMacro(WhitakerSparseLevelSetImage, LevelSetSparseImageBase); 00055 00056 itkStaticConstMacro ( Dimension, unsigned int, VDimension ); 00057 00058 typedef typename Superclass::InputType InputType; 00059 typedef typename Superclass::OutputType OutputType; 00060 typedef typename Superclass::OutputRealType OutputRealType; 00061 typedef typename Superclass::GradientType GradientType; 00062 typedef typename Superclass::HessianType HessianType; 00063 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00064 00065 typedef typename Superclass::LayerIdType LayerIdType; 00066 typedef typename Superclass::LabelObjectType LabelObjectType; 00067 typedef typename Superclass::LabelObjectPointer LabelObjectPointer; 00068 typedef typename Superclass::LabelObjectLengthType LabelObjectLengthType; 00069 typedef typename Superclass::LabelObjectLineType LabelObjectLineType; 00070 00071 typedef typename Superclass::LabelMapType LabelMapType; 00072 typedef typename Superclass::LabelMapPointer LabelMapPointer; 00073 typedef typename Superclass::RegionType RegionType; 00074 00075 typedef typename Superclass::LayerType LayerType; 00076 typedef typename Superclass::LayerIterator LayerIterator; 00077 typedef typename Superclass::LayerConstIterator LayerConstIterator; 00078 00079 typedef typename Superclass::LayerMapType LayerMapType; 00080 typedef typename Superclass::LayerMapIterator LayerMapIterator; 00081 typedef typename Superclass::LayerMapConstIterator LayerMapConstIterator; 00082 00084 using Superclass::Evaluate; 00085 virtual OutputType Evaluate( const InputType& iP ) const; 00086 00087 #ifdef ITK_USE_CONCEPT_CHECKING 00088 00090 itkConceptMacro( DoubleConvertible, 00091 ( Concept::Convertible< OutputRealType, OutputType > ) ); 00092 00094 #endif // ITK_USE_CONCEPT_CHECKING 00095 00096 static inline LayerIdType MinusThreeLayer() { return -3; } 00097 static inline LayerIdType MinusTwoLayer() { return -2; } 00098 static inline LayerIdType MinusOneLayer() { return -1; } 00099 static inline LayerIdType ZeroLayer() { return 0; } 00100 static inline LayerIdType PlusOneLayer() { return 1; } 00101 static inline LayerIdType PlusTwoLayer() { return 2; } 00102 static inline LayerIdType PlusThreeLayer() { return 3; } 00103 00105 template< class TLabel > 00106 typename LabelObject< TLabel, Dimension >::Pointer 00107 GetAsLabelObject() 00108 { 00109 typedef LabelObject< TLabel, Dimension > OutputLabelObjectType; 00110 typename OutputLabelObjectType::Pointer object = OutputLabelObjectType::New(); 00112 00113 for( LayerIdType status = this->MinusThreeLayer(); status < this->PlusOneLayer(); status++ ) 00114 { 00115 LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject( status ); 00116 00117 for( SizeValueType i = 0; i < labelObject->GetNumberOfLines(); i++ ) 00118 { 00119 object->AddLine( labelObject->GetLine( i ) ); 00120 } 00121 } 00122 object->Optimize(); 00123 00124 return object; 00125 } 00126 00127 protected: 00128 00129 WhitakerSparseLevelSetImage(); 00130 virtual ~WhitakerSparseLevelSetImage(); 00131 00133 virtual void InitializeLayers(); 00134 00135 virtual void InitializeInternalLabelList(); 00136 00137 private: 00138 00139 WhitakerSparseLevelSetImage( const Self& ); // purposely not implemented 00140 void operator = ( const Self& ); // purposely not implemented 00141 }; 00142 } 00143 00144 #ifndef ITK_MANUAL_INSTANTIATION 00145 #include "itkWhitakerSparseLevelSetImage.hxx" 00146 #endif 00147 00148 #endif // __itkWhitakerSparseLevelSetImage_h 00149