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 __itkKLMRegionGrowImageFilter_h 00019 #define __itkKLMRegionGrowImageFilter_h 00020 00021 #include "itkImage.h" 00022 #include "itkRegionGrowImageFilter.h" 00023 #include "itkKLMSegmentationBorder.h" 00024 #include "itkImageRegionIterator.h" 00025 #include "itkConceptChecking.h" 00026 #include <algorithm> 00027 #include <functional> 00028 00029 namespace itk 00030 { 00164 template< class TInputImage, class TOutputImage > 00165 class ITK_EXPORT KLMRegionGrowImageFilter:public RegionGrowImageFilter< TInputImage, TOutputImage > 00166 { 00167 public: 00169 typedef KLMRegionGrowImageFilter Self; 00170 typedef RegionGrowImageFilter< TInputImage, TOutputImage > Superclass; 00171 typedef SmartPointer< Self > Pointer; 00172 typedef SmartPointer< const Self > ConstPointer; 00173 00175 itkNewMacro(Self); 00176 00178 itkTypeMacro(KLMRegionGrowImageFilter, RegionGrowImageFilter); 00179 00181 typedef TInputImage InputImageType; 00182 typedef typename TInputImage::Pointer InputImagePointer; 00183 typedef typename TInputImage::ConstPointer InputImageConstPointer; 00184 00186 typedef typename TInputImage::PixelType InputImagePixelType; 00187 00189 typedef typename TInputImage::PixelType::VectorType InputImageVectorType; 00190 00192 itkStaticConstMacro(InputImageVectorDimension, unsigned int, 00193 InputImagePixelType::Dimension); 00194 00196 typedef typename TInputImage::IndexType InputImageIndexType; 00197 00199 typedef ImageRegionIterator< TInputImage > InputImageIterator; 00200 typedef ImageRegionConstIterator< TInputImage > InputImageConstIterator; 00201 00203 typedef typename TInputImage::RegionType InputRegionType; 00204 00207 typedef typename Superclass::GridSizeType GridSizeType; 00208 00210 typedef TOutputImage OutputImageType; 00211 typedef typename TOutputImage::Pointer OutputImagePointer; 00212 00214 itkStaticConstMacro(InputImageDimension, unsigned int, 00215 TInputImage::ImageDimension); 00216 00218 itkStaticConstMacro(OutputImageDimension, unsigned int, 00219 TOutputImage::ImageDimension); 00220 00222 typedef typename TOutputImage::PixelType OutputImagePixelType; 00223 00225 typedef typename TOutputImage::PixelType::VectorType OutputImageVectorType; 00226 00228 itkStaticConstMacro(OutputImageVectorDimension, unsigned int, 00229 OutputImagePixelType::Dimension); 00230 00232 typedef typename TOutputImage::IndexType OutputImageIndexType; 00233 00235 typedef ImageRegionIterator< TOutputImage > OutputImageIterator; 00236 00238 typedef typename KLMSegmentationRegion::RegionLabelType RegionLabelType; 00239 00241 itkStaticConstMacro(LabelImageDimension, RegionLabelType, 00242 InputImageDimension); 00243 00245 typedef Image< RegionLabelType, itkGetStaticConstMacro(LabelImageDimension) > LabelImageType; 00246 00248 typedef typename LabelImageType::Pointer LabelImagePointer; 00249 00251 typedef typename LabelImageType::PixelType LabelImagePixelType; 00252 00254 typedef typename LabelImageType::IndexType LabelImageIndexType; 00255 00257 typedef ImageRegionIterator< LabelImageType > LabelImageIterator; 00258 00260 typedef vnl_vector< double > MeanRegionIntensityType; 00261 00263 typedef KLMSegmentationBorder BorderType; 00264 00266 typedef KLMDynamicBorderArray< BorderType > KLMSegmentationBorderArrayPtr; 00267 00271 itkSetMacro(MaximumLambda, double); 00272 itkGetConstReferenceMacro(MaximumLambda, double); 00274 00276 itkSetMacro(NumberOfRegions, unsigned int); 00277 itkGetConstReferenceMacro(NumberOfRegions, unsigned int); 00279 00281 LabelImagePointer GetLabelledImage(void); 00282 00284 void PrintAlgorithmRegionStats(void); 00285 00287 void PrintAlgorithmBorderStats(void); 00288 00289 #ifdef ITK_USE_CONCEPT_CHECKING 00290 00291 itkConceptMacro( InputHasNumericTraitsCheck, 00292 ( Concept::HasNumericTraits< typename InputImagePixelType::ValueType > ) ); 00293 itkConceptMacro( SameDimension, 00294 ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension), 00295 itkGetStaticConstMacro(OutputImageDimension) > ) ); 00296 #if defined(THIS_CONCEPT_FAILS_ON_GCC) 00297 00299 itkConceptMacro( SameVectorDimension, 00300 ( Concept::SameDimension< itkGetStaticConstMacro(InputImageVectorDimension), 00301 itkGetStaticConstMacro(OutputImageVectorDimension) > ) ); 00302 #endif 00303 00305 #endif 00306 protected: 00307 KLMRegionGrowImageFilter(); 00308 ~KLMRegionGrowImageFilter(); 00309 void PrintSelf(std::ostream & os, Indent indent) const; 00311 00315 virtual void GenerateData(); 00316 00320 virtual void GenerateInputRequestedRegion(); 00321 00326 virtual void EnlargeOutputRequestedRegion(DataObject *); 00327 00330 void ApplyRegionGrowImageFilter(); 00331 00335 virtual void MergeRegions(); 00336 00338 virtual void GenerateOutputImage(); 00339 00341 void ApplyKLM(); 00342 00344 void InitializeKLM(); 00345 00347 LabelImagePointer GenerateLabelledImage(LabelImageType *labelImagePtr); 00348 00354 virtual void InitializeRegionParameters(InputRegionType region); 00355 00359 virtual void ResolveRegions(); 00360 00361 private: 00362 KLMRegionGrowImageFilter(const Self &); // purposely not implemented 00363 void operator=(const Self &); // purposely not implemented 00364 00365 typedef typename TInputImage::SizeType InputImageSizeType; 00366 typedef typename KLMSegmentationRegion::Pointer KLMSegmentationRegionPtr; 00367 typedef typename KLMSegmentationBorder::Pointer KLMSegmentationBorderPtr; 00368 00369 double m_MaximumLambda; 00370 unsigned int m_NumberOfRegions; 00371 00374 double m_InternalLambda; 00375 unsigned int m_InitialNumberOfRegions; 00376 double m_TotalBorderLength; 00377 00378 std::vector< KLMSegmentationRegionPtr > m_RegionsPointer; 00379 std::vector< KLMSegmentationBorderPtr > m_BordersPointer; 00380 std::vector< KLMSegmentationBorderArrayPtr > m_BordersDynamicPointer; 00381 KLMSegmentationBorderArrayPtr * m_BorderCandidate; 00382 00383 MeanRegionIntensityType m_InitialRegionMean; 00384 double m_InitialRegionArea; 00385 }; // class KLMRegionGrowImageFilter 00386 } // namespace itk 00387 00388 #ifndef ITK_MANUAL_INSTANTIATION 00389 #include "itkKLMRegionGrowImageFilter.hxx" 00390 #endif 00391 00392 #endif 00393