ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLabelVotingImageFilter.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 __itkLabelVotingImageFilter_h
00019 #define __itkLabelVotingImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 
00023 namespace itk
00024 {
00074 template< typename TInputImage, typename TOutputImage = TInputImage >
00075 class ITK_EXPORT LabelVotingImageFilter:
00076   public ImageToImageFilter< TInputImage, TOutputImage >
00077 {
00078 public:
00080   typedef LabelVotingImageFilter                          Self;
00081   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00082   typedef SmartPointer< Self >                            Pointer;
00083   typedef SmartPointer< const Self >                      ConstPointer;
00084 
00086   itkNewMacro(Self);
00087 
00089   itkTypeMacro(LabelVotingImageFilter, ImageToImageFilter);
00090 
00093   typedef typename TOutputImage::PixelType OutputPixelType;
00094   typedef typename TInputImage::PixelType  InputPixelType;
00095 
00098   itkStaticConstMacro(InputImageDimension, unsigned int,
00099                       TInputImage::ImageDimension);
00100   itkStaticConstMacro(ImageDimension, unsigned int,
00101                       TOutputImage::ImageDimension);
00103 
00105   typedef TInputImage                           InputImageType;
00106   typedef TOutputImage                          OutputImageType;
00107   typedef typename InputImageType::ConstPointer InputImagePointer;
00108   typedef typename OutputImageType::Pointer     OutputImagePointer;
00109 
00111   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00112 
00115   void SetLabelForUndecidedPixels(const OutputPixelType l)
00116   {
00117     this->m_LabelForUndecidedPixels = l;
00118     this->m_HasLabelForUndecidedPixels = true;
00119     this->Modified();
00120   }
00122 
00129   OutputPixelType GetLabelForUndecidedPixels() const
00130   {
00131     return this->m_LabelForUndecidedPixels;
00132   }
00133 
00136   void UnsetLabelForUndecidedPixels()
00137   {
00138     if ( this->m_HasLabelForUndecidedPixels )
00139       {
00140       this->m_HasLabelForUndecidedPixels = false;
00141       this->Modified();
00142       }
00143   }
00145 
00146 #ifdef ITK_USE_CONCEPT_CHECKING
00147 
00148   itkConceptMacro( InputConvertibleToOutputCheck,
00149                    ( Concept::Convertible< InputPixelType, OutputPixelType > ) );
00150   itkConceptMacro( IntConvertibleToInputCheck,
00151                    ( Concept::Convertible< int, InputPixelType > ) );
00152   itkConceptMacro( SameDimensionCheck,
00153                    ( Concept::SameDimension< InputImageDimension, ImageDimension > ) );
00154   itkConceptMacro( InputConvertibleToUnsignedIntCheck,
00155                    ( Concept::Convertible< InputPixelType, unsigned int > ) );
00156   itkConceptMacro( IntConvertibleToOutputPixelType,
00157                    ( Concept::Convertible< int, OutputPixelType > ) );
00158   itkConceptMacro( InputPlusIntCheck,
00159                    ( Concept::AdditiveOperators< InputPixelType, int > ) );
00160   itkConceptMacro( InputIncrementDecrementOperatorsCheck,
00161                    ( Concept::IncrementDecrementOperators< InputPixelType > ) );
00162   itkConceptMacro( OutputOStreamWritableCheck,
00163                    ( Concept::OStreamWritable< OutputPixelType > ) );
00164 
00166 #endif
00167 protected:
00168   LabelVotingImageFilter() { this->m_HasLabelForUndecidedPixels = false; }
00169   virtual ~LabelVotingImageFilter() {}
00171 
00174   void BeforeThreadedGenerateData();
00175 
00176   void ThreadedGenerateData
00177     (const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId);
00178 
00179   void PrintSelf(std::ostream &, Indent) const;
00180 
00182   InputPixelType ComputeMaximumInputValue();
00183 
00184 private:
00185   LabelVotingImageFilter(const Self &); //purposely not implemented
00186   void operator=(const Self &);         //purposely not implemented
00187 
00188   OutputPixelType m_LabelForUndecidedPixels;
00189   bool            m_HasLabelForUndecidedPixels;
00190   InputPixelType  m_TotalLabelCount;
00191 };
00192 } // end namespace itk
00193 
00194 #ifndef ITK_MANUAL_INSTANTIATION
00195 #include "itkLabelVotingImageFilter.hxx"
00196 #endif
00197 
00198 #endif
00199