ITK  4.0.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 TOutputImage                                        OutputImageType;
00061   typedef typename OutputImageType::PixelType                 OutputPixelType;
00062   typedef typename OutputImageType::RegionType                OutputImageRegionType;
00063   typedef typename NumericTraits< OutputPixelType >::RealType RealType;
00064   typedef typename NumericTraits< RealType >::AccumulateType  AccumulateType;
00065 
00067   virtual void SetValidInput(const InputImageType *validImage);
00068 
00070   virtual void SetTestInput(const InputImageType *testImage);
00071 
00074   itkSetMacro(ToleranceRadius, int);
00075   itkGetConstMacro(ToleranceRadius, int);
00077 
00080   itkSetMacro(DifferenceThreshold, OutputPixelType);
00081   itkGetConstMacro(DifferenceThreshold, OutputPixelType);
00083 
00087   itkSetMacro(IgnoreBoundaryPixels, bool);
00088   itkGetConstMacro(IgnoreBoundaryPixels, bool);
00090 
00092   itkGetConstMacro(MeanDifference, RealType);
00093   itkGetConstMacro(TotalDifference, AccumulateType);
00094   itkGetConstMacro(NumberOfPixelsWithDifferences, SizeValueType);
00096 
00098   using Superclass::SetInput;
00099   virtual void SetInput(const TInputImage *image);
00100   virtual void SetInput(unsigned int, const TInputImage *image);
00101   const TInputImage * GetInput(void) const;
00102   const TInputImage * GetInput(unsigned int idx) const;
00104 
00105 protected:
00106   ComparisonImageFilter();
00107   virtual ~ComparisonImageFilter() {}
00108 
00109   void PrintSelf(std::ostream & os, Indent indent) const;
00110 
00120   void ThreadedGenerateData(const OutputImageRegionType & threadRegion,
00121                             ThreadIdType threadId);
00122 
00123   void BeforeThreadedGenerateData();
00124 
00125   void AfterThreadedGenerateData();
00126 
00127   OutputPixelType m_DifferenceThreshold;
00128 
00129   RealType m_MeanDifference;
00130 
00131   AccumulateType m_TotalDifference;
00132 
00133   SizeValueType m_NumberOfPixelsWithDifferences;
00134 
00135   int m_ToleranceRadius;
00136 
00137   Array< AccumulateType >    m_ThreadDifferenceSum;
00138   Array< SizeValueType >     m_ThreadNumberOfPixels;
00139 
00140 private:
00141   ComparisonImageFilter(const Self &); //purposely not implemented
00142   void operator=(const Self &);        //purposely not implemented
00143 
00144   bool m_IgnoreBoundaryPixels;
00145 };
00146 } // end namespace Testing
00147 } // end namespace itk
00148 
00149 #ifndef ITK_MANUAL_INSTANTIATION
00150 #include "itkTestingComparisonImageFilter.hxx"
00151 #endif
00152 
00153 
00154 #endif
00155