ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkVoronoiSegmentationRGBImageFilter.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 __itkVoronoiSegmentationRGBImageFilter_h
00019 #define __itkVoronoiSegmentationRGBImageFilter_h
00020 
00021 #include "itkVoronoiSegmentationImageFilterBase.h"
00022 
00023 namespace itk
00024 {
00053 template< class TInputImage, class TOutputImage >
00054 class ITK_EXPORT VoronoiSegmentationRGBImageFilter:
00055   public VoronoiSegmentationImageFilterBase< TInputImage, TOutputImage >
00056 {
00057 public:
00059   typedef VoronoiSegmentationRGBImageFilter                               Self;
00060   typedef VoronoiSegmentationImageFilterBase< TInputImage, TOutputImage > Superclass;
00061   typedef SmartPointer< Self >                                            Pointer;
00062   typedef SmartPointer< const Self >                                      ConstPointer;
00063 
00065   itkTypeMacro(VoronoiSegmentationRGBImageFilter,
00066                VoronoiSegmentationImageFilterBase);
00067 
00069   itkNewMacro(Self);
00070 
00072   typedef typename Superclass::BinaryObjectImage BinaryObjectImage;
00073   typedef typename Superclass::IndexList         IndexList;
00074   typedef typename Superclass::IndexType         IndexType;
00075   typedef typename Superclass::RegionType        RegionType;
00076   typedef typename Superclass::PixelType         PixelType;
00077   typedef typename Superclass::InputImagePointer InputImagePointer;
00078   typedef typename Superclass::InputImageType    InputImageType;
00079   typedef Vector< float, 6 >                     RGBHCVPixel;
00080   typedef Image< RGBHCVPixel >                   RGBHCVImage;
00081 
00083   void SetMeanPercentError(double x[6]);
00084   void SetSTDPercentError(double x[6]);
00085   void GetMeanPercentError(double x[6]){ for ( int i = 0; i < 6; i++ ) { x[i] = m_MeanPercentError[i]; } }
00086   void GetSTDPercentError(double x[6]){ for ( int i = 0; i < 6; i++ ) { x[i] = m_STDPercentError[i]; } }
00087   void GetMean(double x[6]){ for ( int i = 0; i < 6; i++ ) { x[i] = m_Mean[i]; } }
00088   void GetSTD(double x[6]){ for ( int i = 0; i < 6; i++ ) { x[i] = m_STD[i]; } }
00089   void SetMean(double x[6]){ for ( int i = 0; i < 6; i++ ) { m_Mean[i] = x[i]; } }
00090   void SetSTD(double x[6]){ for ( int i = 0; i < 6; i++ ) { m_STD[i] = x[i]; } }
00091   void GetMeanTolerance(double x[6]){ for ( int i = 0; i < 6; i++ ) { x[i] = m_MeanTolerance[i]; } }
00092   void GetSTDTolerance(double x[6]){ for ( int i = 0; i < 6; i++ ) { x[i] = m_STDTolerance[i]; } }
00094 
00098   itkSetMacro(MaxValueOfRGB, double);
00099   itkGetConstMacro(MaxValueOfRGB, double);
00101 
00104   void SetTestMean(unsigned int t1, unsigned int t2, unsigned int t3)
00105   {
00106     m_TestMean[0] = t1;
00107     m_TestMean[1] = t2;
00108     m_TestMean[2] = t3;
00109   }
00110 
00111   void SetTestSTD(unsigned int t1, unsigned int t2, unsigned int t3)
00112   {
00113     m_TestSTD[0] = t1;
00114     m_TestSTD[1] = t2;
00115     m_TestSTD[2] = t3;
00116   }
00117 
00118   void GetTestMean(unsigned int x[3])
00119   {
00120     x[0] = m_TestMean[0]; x[1] = m_TestMean[1]; x[2] = m_TestMean[2];
00121   }
00122 
00123   void GetTestSTD(unsigned int x[3])
00124   {
00125     x[0] = m_TestSTD[0]; x[1] = m_TestSTD[1]; x[2] = m_TestSTD[2];
00126   }
00127 
00128   void TakeAPrior(const BinaryObjectImage *aprior);
00129 
00130   using Superclass::SetInput;
00131   virtual void SetInput(const InputImageType *input);
00132 
00133   virtual void SetInput(unsigned int, const InputImageType *image);
00134 
00136   itkStaticConstMacro(InputImageDimension, unsigned int,
00137                       TInputImage::ImageDimension);
00138   itkStaticConstMacro(OutputImageDimension, unsigned int,
00139                       TOutputImage::ImageDimension);
00141 
00142 #ifdef ITK_USE_CONCEPT_CHECKING
00143 
00144   itkConceptMacro( SameDimensionCheck,
00145                    ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
00146   itkConceptMacro( IntConvertibleToOutputCheck,
00147                    ( Concept::Convertible< int, typename TOutputImage::PixelType > ) );
00148 
00150 #endif
00151 protected:
00152   VoronoiSegmentationRGBImageFilter();
00153   ~VoronoiSegmentationRGBImageFilter();
00154   void PrintSelf(std::ostream & os, Indent indent) const;
00156 
00157 private:
00158   double m_Mean[6];
00159   double m_STD[6];
00160   double m_MeanTolerance[6];
00161   double m_STDTolerance[6];
00162   double m_MeanPercentError[6];
00163   double m_STDPercentError[6];
00164   double m_MaxValueOfRGB;
00165   unsigned int m_TestMean[3];
00166   unsigned int m_TestSTD[3];
00167   typename RGBHCVImage::Pointer m_WorkingImage;
00168 
00169   virtual bool TestHomogeneity(IndexList & Plist);
00170 
00171 private:
00172   VoronoiSegmentationRGBImageFilter(const Self &); //purposely not implemented
00173   void operator=(const Self &);                    //purposely not implemented
00174 };
00175 } //end namespace
00176 
00177 #ifndef ITK_MANUAL_INSTANTIATION
00178 #include "itkVoronoiSegmentationRGBImageFilter.hxx"
00179 #endif
00180 
00181 #endif
00182