ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkConnectedThresholdImageFilter.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 __itkConnectedThresholdImageFilter_h
00019 #define __itkConnectedThresholdImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkSimpleDataObjectDecorator.h"
00023 
00024 namespace itk
00025 {
00036 template< class TInputImage, class TOutputImage >
00037 class ITK_EXPORT ConnectedThresholdImageFilter:
00038   public ImageToImageFilter< TInputImage, TOutputImage >
00039 {
00040 public:
00042   typedef ConnectedThresholdImageFilter                   Self;
00043   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00044   typedef SmartPointer< Self >                            Pointer;
00045   typedef SmartPointer< const Self >                      ConstPointer;
00046 
00048   itkNewMacro(Self);
00049 
00051   itkTypeMacro(ConnectedThresholdImageFilter,
00052                ImageToImageFilter);
00053 
00054   typedef TInputImage                           InputImageType;
00055   typedef typename InputImageType::Pointer      InputImagePointer;
00056   typedef typename InputImageType::ConstPointer InputImageConstPointer;
00057   typedef typename InputImageType::RegionType   InputImageRegionType;
00058   typedef typename InputImageType::PixelType    InputImagePixelType;
00059   typedef typename InputImageType::IndexType    IndexType;
00060   typedef typename std::vector<IndexType>       SeedContainerType;
00061   typedef typename InputImageType::SizeType     SizeType;
00062 
00063   typedef TOutputImage                         OutputImageType;
00064   typedef typename OutputImageType::Pointer    OutputImagePointer;
00065   typedef typename OutputImageType::RegionType OutputImageRegionType;
00066   typedef typename OutputImageType::PixelType  OutputImagePixelType;
00067 
00068   void PrintSelf(std::ostream & os, Indent indent) const;
00069 
00071   void SetSeed(const IndexType & seed);
00072 
00073   void AddSeed(const IndexType & seed);
00074 
00076   void ClearSeeds();
00077 
00079   virtual const SeedContainerType &GetSeeds() const;
00080 
00084   itkSetMacro(ReplaceValue, OutputImagePixelType);
00085   itkGetConstMacro(ReplaceValue, OutputImagePixelType);
00087 
00089   typedef SimpleDataObjectDecorator< InputImagePixelType > InputPixelObjectType;
00090 
00092   virtual void SetUpper(InputImagePixelType);
00093   virtual void SetLower(InputImagePixelType);
00095 
00097   virtual void SetUpperInput(const InputPixelObjectType *);
00098 
00099   virtual void SetLowerInput(const InputPixelObjectType *);
00100 
00102   virtual InputImagePixelType GetUpper() const;
00103 
00104   virtual InputImagePixelType GetLower() const;
00105 
00107   virtual InputPixelObjectType * GetUpperInput();
00108 
00109   virtual InputPixelObjectType * GetLowerInput();
00110 
00112   itkStaticConstMacro(InputImageDimension, unsigned int,
00113                       TInputImage::ImageDimension);
00114   itkStaticConstMacro(OutputImageDimension, unsigned int,
00115                       TOutputImage::ImageDimension);
00117 
00118 #ifdef ITK_USE_CONCEPT_CHECKING
00119 
00120   itkConceptMacro( OutputEqualityComparableCheck,
00121                    ( Concept::EqualityComparable< OutputImagePixelType > ) );
00122   itkConceptMacro( InputEqualityComparableCheck,
00123                    ( Concept::EqualityComparable< InputImagePixelType > ) );
00124   itkConceptMacro( InputConvertibleToOutputCheck,
00125                    ( Concept::Convertible< InputImagePixelType, OutputImagePixelType > ) );
00126   itkConceptMacro( SameDimensionCheck,
00127                    ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
00128   itkConceptMacro( IntConvertibleToInputCheck,
00129                    ( Concept::Convertible< int, InputImagePixelType > ) );
00130   itkConceptMacro( OutputOStreamWritableCheck,
00131                    ( Concept::OStreamWritable< OutputImagePixelType > ) );
00132 
00134 #endif
00135 
00139   typedef enum { FaceConnectivity, FullConnectivity } ConnectivityEnumType;
00140 
00143   itkSetEnumMacro(Connectivity, ConnectivityEnumType);
00144   itkGetEnumMacro(Connectivity, ConnectivityEnumType);
00146 
00147 protected:
00148   ConnectedThresholdImageFilter();
00149   ~ConnectedThresholdImageFilter(){}
00150   SeedContainerType m_Seeds;
00151 
00152   InputImagePixelType m_Lower;
00153   InputImagePixelType m_Upper;
00154 
00155   OutputImagePixelType m_ReplaceValue;
00156 
00157   // Override since the filter needs all the data for the algorithm
00158   void GenerateInputRequestedRegion();
00159 
00160   // Override since the filter produces the entire dataset
00161   void EnlargeOutputRequestedRegion(DataObject *output);
00162 
00163   void GenerateData();
00164 
00165   // Type of connectivity to use.
00166   ConnectivityEnumType m_Connectivity;
00167 private:
00168   ConnectedThresholdImageFilter(const Self &); //purposely not implemented
00169   void operator=(const Self &);                //purposely not implemented
00170 };
00171 } // end namespace itk
00172 
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174 #include "itkConnectedThresholdImageFilter.hxx"
00175 #endif
00176 
00177 #endif
00178