ITK  4.0.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 {
00072 template< class TInputImage, class TOutputImage = TInputImage >
00073 class ITK_EXPORT ThresholdMaximumConnectedComponentsImageFilter:
00074   public ImageToImageFilter< TInputImage, TOutputImage >
00075 {
00076 public:
00078   typedef ThresholdMaximumConnectedComponentsImageFilter  Self;
00079   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00080   typedef SmartPointer< Self >                            Pointer;
00081   typedef SmartPointer< const Self >                      ConstPointer;
00082 
00084   itkNewMacro(Self);
00085 
00087   itkTypeMacro(ThresholdMaximumConnectedComponentsImageFilter,
00088                ImageToImageFilter);
00089 
00091   typedef typename TInputImage::PixelType PixelType;
00092 
00094   itkConceptMacro( PixelTypeComparable, ( Concept::Comparable< PixelType > ) );
00095 
00103   itkSetMacro(MinimumObjectSizeInPixels, unsigned int);
00104   itkGetConstMacro(MinimumObjectSizeInPixels, unsigned int);
00106 
00120   itkSetMacro(InsideValue, PixelType);
00121   itkSetMacro(OutsideValue, PixelType);
00122   itkSetMacro(UpperBoundary, PixelType);
00123   itkGetConstMacro(InsideValue, PixelType);
00124   itkGetConstMacro(OutsideValue, PixelType);
00125   itkGetConstMacro(UpperBoundary, PixelType);
00127 
00132   itkGetConstMacro(NumberOfObjects, SizeValueType);
00133 
00137   itkGetConstMacro(ThresholdValue, PixelType);
00138 
00140   typedef TInputImage                           InputImageType;
00141   typedef typename InputImageType::ConstPointer InputImagePointer;
00142   typedef typename InputImageType::RegionType   InputImageRegionType;
00143   typedef typename InputImageType::PixelType    InputImagePixelType;
00144 
00146   typedef TOutputImage                         OutputImageType;
00147   typedef typename OutputImageType::Pointer    OutputImagePointer;
00148   typedef typename OutputImageType::RegionType OutputImageRegionType;
00149   typedef typename OutputImageType::PixelType  OutputImagePixelType;
00150 protected:
00151   ThresholdMaximumConnectedComponentsImageFilter();
00152   ~ThresholdMaximumConnectedComponentsImageFilter() {}
00153   void PrintSelf(std::ostream & os, Indent indent) const;
00155 
00158   void GenerateData(void);
00159 
00164   SizeValueType ComputeConnectedComponents(void);
00165 
00166 private:
00167 
00169   typedef unsigned int FilterPixelType;
00170 
00171   itkStaticConstMacro(ImageDimension,
00172                       unsigned int,
00173                       TInputImage::ImageDimension);
00174 
00175   typedef itk::Image< FilterPixelType, itkGetStaticConstMacro(ImageDimension) >
00176   FilterImageType;
00177 
00178   typedef typename FilterImageType::Pointer FilterImagePointer;
00179 
00180   //purposely not implemented
00181   ThresholdMaximumConnectedComponentsImageFilter(const Self &);
00182   void operator=(const Self &); //purposely not implemented
00183 
00184   //
00185   // Binary Threshold Filter
00186   //
00187   typedef BinaryThresholdImageFilter< InputImageType, OutputImageType >
00188   ThresholdFilterType;
00189 
00190   //
00191   // Connected Components Filter
00192   //
00193   typedef ConnectedComponentImageFilter< OutputImageType, FilterImageType >
00194   ConnectedFilterType;
00195 
00196   //
00197   // Relabeled Components Filter
00198   //
00199   typedef RelabelComponentImageFilter< FilterImageType, FilterImageType >
00200   RelabelFilterType;
00201 
00202   //
00203   // Minimum maximum calculator
00204   //
00205   typedef MinimumMaximumImageCalculator< InputImageType > MinMaxCalculatorType;
00206 
00207   //
00208   // Declare member variables for the filters of the internal pipeline.
00209   //
00210   typename ThresholdFilterType::Pointer m_ThresholdFilter;
00211   typename ConnectedFilterType::Pointer m_ConnectedComponent;
00212 
00213   typename RelabelFilterType::Pointer m_LabeledComponent;
00214 
00215   typename MinMaxCalculatorType::Pointer m_MinMaxCalculator;
00216 
00217   // Variables defined by the user
00218   unsigned int m_MinimumObjectSizeInPixels;
00219 
00220   // Binary threshold variables
00221   PixelType m_OutsideValue;
00222   PixelType m_InsideValue;
00223   PixelType m_LowerBoundary;
00224   PixelType m_UpperBoundary;
00225 
00226   // Filter variables
00227   PixelType     m_ThresholdValue;
00228   SizeValueType m_NumberOfObjects;
00229 };
00230 } // end namespace itk
00231 
00232 #ifndef ITK_MANUAL_INSTANTIATION
00233 #include "itkThresholdMaximumConnectedComponentsImageFilter.hxx"
00234 #endif
00235 
00236 #endif
00237