ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkThresholdMaximumConnectedComponentsImageFilter.h
Go to the documentation of this file.
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 __itkThresholdMaximumConnectedComponentsImageFilter_h
00019 #define __itkThresholdMaximumConnectedComponentsImageFilter_h
00020 
00021 #include "itkBinaryThresholdImageFilter.h"
00022 #include "itkConnectedComponentImageFilter.h"
00023 #include "itkRelabelComponentImageFilter.h"
00024 #include "itkMinimumMaximumImageCalculator.h"
00025 #include "itkCastImageFilter.h"
00026 
00027 
00028 namespace itk
00029 {
00073 template< class TInputImage, class TOutputImage = TInputImage >
00074 class ITK_EXPORT ThresholdMaximumConnectedComponentsImageFilter:
00075   public ImageToImageFilter< TInputImage, TOutputImage >
00076 {
00077 public:
00079   typedef ThresholdMaximumConnectedComponentsImageFilter  Self;
00080   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00081   typedef SmartPointer< Self >                            Pointer;
00082   typedef SmartPointer< const Self >                      ConstPointer;
00083 
00085   itkNewMacro(Self);
00086 
00088   itkTypeMacro(ThresholdMaximumConnectedComponentsImageFilter,
00089                ImageToImageFilter);
00090 
00092   typedef typename TInputImage::PixelType PixelType;
00093 
00095   itkConceptMacro( PixelTypeComparable, ( Concept::Comparable< PixelType > ) );
00096 
00104   itkSetMacro(MinimumObjectSizeInPixels, unsigned int);
00105   itkGetConstMacro(MinimumObjectSizeInPixels, unsigned int);
00107 
00121   itkSetMacro(InsideValue, PixelType);
00122   itkSetMacro(OutsideValue, PixelType);
00123   itkSetMacro(UpperBoundary, PixelType);
00124   itkGetConstMacro(InsideValue, PixelType);
00125   itkGetConstMacro(OutsideValue, PixelType);
00126   itkGetConstMacro(UpperBoundary, PixelType);
00128 
00133   itkGetConstMacro(NumberOfObjects, SizeValueType);
00134 
00138   itkGetConstMacro(ThresholdValue, PixelType);
00139 
00141   typedef TInputImage                           InputImageType;
00142   typedef typename InputImageType::ConstPointer InputImagePointer;
00143   typedef typename InputImageType::RegionType   InputImageRegionType;
00144   typedef typename InputImageType::PixelType    InputImagePixelType;
00145 
00147   typedef TOutputImage                         OutputImageType;
00148   typedef typename OutputImageType::Pointer    OutputImagePointer;
00149   typedef typename OutputImageType::RegionType OutputImageRegionType;
00150   typedef typename OutputImageType::PixelType  OutputImagePixelType;
00151 protected:
00152   ThresholdMaximumConnectedComponentsImageFilter();
00153   ~ThresholdMaximumConnectedComponentsImageFilter() {}
00154   void PrintSelf(std::ostream & os, Indent indent) const;
00156 
00159   void GenerateData(void);
00160 
00165   SizeValueType ComputeConnectedComponents(void);
00166 
00167 private:
00168 
00170   typedef unsigned int FilterPixelType;
00171 
00172   itkStaticConstMacro(ImageDimension,
00173                       unsigned int,
00174                       TInputImage::ImageDimension);
00175 
00176   typedef itk::Image< FilterPixelType, itkGetStaticConstMacro(ImageDimension) >
00177   FilterImageType;
00178 
00179   typedef typename FilterImageType::Pointer FilterImagePointer;
00180 
00181   //purposely not implemented
00182   ThresholdMaximumConnectedComponentsImageFilter(const Self &);
00183   void operator=(const Self &); //purposely not implemented
00184 
00185   //
00186   // Binary Threshold Filter
00187   //
00188   typedef BinaryThresholdImageFilter< InputImageType, OutputImageType >
00189   ThresholdFilterType;
00190 
00191   //
00192   // Connected Components Filter
00193   //
00194   typedef ConnectedComponentImageFilter< OutputImageType, FilterImageType >
00195   ConnectedFilterType;
00196 
00197   //
00198   // Relabeled Components Filter
00199   //
00200   typedef RelabelComponentImageFilter< FilterImageType, FilterImageType >
00201   RelabelFilterType;
00202 
00203   //
00204   // Minimum maximum calculator
00205   //
00206   typedef MinimumMaximumImageCalculator< InputImageType > MinMaxCalculatorType;
00207 
00208   //
00209   // Declare member variables for the filters of the internal pipeline.
00210   //
00211   typename ThresholdFilterType::Pointer m_ThresholdFilter;
00212   typename ConnectedFilterType::Pointer m_ConnectedComponent;
00213 
00214   typename RelabelFilterType::Pointer m_LabeledComponent;
00215 
00216   typename MinMaxCalculatorType::Pointer m_MinMaxCalculator;
00217 
00218   // Variables defined by the user
00219   unsigned int m_MinimumObjectSizeInPixels;
00220 
00221   // Binary threshold variables
00222   PixelType m_OutsideValue;
00223   PixelType m_InsideValue;
00224   PixelType m_LowerBoundary;
00225   PixelType m_UpperBoundary;
00226 
00227   // Filter variables
00228   PixelType     m_ThresholdValue;
00229   SizeValueType m_NumberOfObjects;
00230 };
00231 } // end namespace itk
00232 
00233 #ifndef ITK_MANUAL_INSTANTIATION
00234 #include "itkThresholdMaximumConnectedComponentsImageFilter.hxx"
00235 #endif
00236 
00237 #endif
00238