ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkTestingComparisonImageFilter.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 __itkTestingComparisonImageFilter_h
00019 #define __itkTestingComparisonImageFilter_h
00020 
00021 #include "itkArray.h"
00022 #include "itkNumericTraits.h"
00023 #include "itkImageSource.h"
00024 
00025 namespace itk
00026 {
00027 namespace Testing
00028 {
00041 template< class TInputImage, class TOutputImage >
00042 class ITK_EXPORT ComparisonImageFilter:
00043   public ImageSource< TOutputImage >
00044 {
00045 public:
00047   typedef ComparisonImageFilter             Self;
00048   typedef ImageSource< TOutputImage >       Superclass;
00049   typedef SmartPointer< Self >              Pointer;
00050   typedef SmartPointer< const Self >        ConstPointer;
00051 
00053   itkNewMacro(Self);
00054 
00056   itkTypeMacro(ComparisonImageFilter, ImageSource);
00057 
00059   typedef TInputImage                                         InputImageType;
00060   typedef typename InputImageType::PixelType                  InputPixelType;
00061   typedef TOutputImage                                        OutputImageType;
00062   typedef typename OutputImageType::PixelType                 OutputPixelType;
00063   typedef typename OutputImageType::RegionType                OutputImageRegionType;
00064   typedef typename NumericTraits< OutputPixelType >::RealType RealType;
00065   typedef typename NumericTraits< RealType >::AccumulateType  AccumulateType;
00066 
00068   virtual void SetValidInput(const InputImageType *validImage);
00069 
00071   virtual void SetTestInput(const InputImageType *testImage);
00072 
00075   itkSetMacro(ToleranceRadius, int);
00076   itkGetConstMacro(ToleranceRadius, int);
00078 
00081   itkSetMacro(DifferenceThreshold, OutputPixelType);
00082   itkGetConstMacro(DifferenceThreshold, OutputPixelType);
00084 
00088   itkSetMacro(IgnoreBoundaryPixels, bool);
00089   itkGetConstMacro(IgnoreBoundaryPixels, bool);
00091 
00094   itkGetConstMacro(MinimumDifference, OutputPixelType);
00095   itkGetConstMacro(MaximumDifference, OutputPixelType);
00096   itkGetConstMacro(MeanDifference, RealType);
00097   itkGetConstMacro(TotalDifference, AccumulateType);
00098   itkGetConstMacro(NumberOfPixelsWithDifferences, SizeValueType);
00100 
00102   using Superclass::SetInput;
00103   virtual void SetInput(const TInputImage *image);
00104   virtual void SetInput(unsigned int, const TInputImage *image);
00105   const TInputImage * GetInput(void) const;
00106   const TInputImage * GetInput(unsigned int idx) const;
00108 
00109 protected:
00110   ComparisonImageFilter();
00111   virtual ~ComparisonImageFilter() {}
00112 
00113   void PrintSelf(std::ostream & os, Indent indent) const;
00114 
00124   void ThreadedGenerateData(const OutputImageRegionType & threadRegion,
00125                             ThreadIdType threadId);
00126 
00127   void BeforeThreadedGenerateData();
00128 
00129   void AfterThreadedGenerateData();
00130 
00131   OutputPixelType m_DifferenceThreshold;
00132 
00133   RealType        m_MeanDifference;
00134   OutputPixelType m_MinimumDifference;
00135   OutputPixelType m_MaximumDifference;
00136 
00137   AccumulateType m_TotalDifference;
00138 
00139   SizeValueType m_NumberOfPixelsWithDifferences;
00140 
00141   int m_ToleranceRadius;
00142 
00143   Array< AccumulateType >    m_ThreadDifferenceSum;
00144   Array< SizeValueType >     m_ThreadNumberOfPixels;
00145 
00146   Array< OutputPixelType >    m_ThreadMinimumDifference;
00147   Array< OutputPixelType >    m_ThreadMaximumDifference;
00148 
00149 private:
00150   ComparisonImageFilter(const Self &); //purposely not implemented
00151   void operator=(const Self &);        //purposely not implemented
00152 
00153   bool m_IgnoreBoundaryPixels;
00154 };
00155 } // end namespace Testing
00156 } // end namespace itk
00157 
00158 #ifndef ITK_MANUAL_INSTANTIATION
00159 #include "itkTestingComparisonImageFilter.hxx"
00160 #endif
00161 
00162 
00163 #endif
00164