| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkDifferenceImageFilter.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:34 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkDifferenceImageFilter_h |
| 18 |
|
#define __itkDifferenceImageFilter_h |
| 19 |
|
|
| 20 |
|
#include "itkImageToImageFilter.h" |
| 21 |
|
#include "itkNumericTraits.h" |
| 22 |
|
#include "itkArray.h" |
| 23 |
|
|
| 24 |
|
namespace itk |
| 25 |
|
{ |
| 26 |
|
|
| 27 |
|
/** \class DifferenceImageFilter |
| 28 |
|
* \brief Implements pixel-wise comparison of two images. |
| 29 |
|
* |
| 30 |
|
* This filter is used by the testing system to compute the difference |
| 31 |
|
* between a valid image and an image produced by the test. |
| 32 |
|
* |
| 33 |
|
* \ingroup IntensityImageFilters Multithreaded |
| 34 |
|
*/ |
| 35 |
|
template <class TInputImage, class TOutputImage> |
| 36 |
|
class ITK_EXPORT DifferenceImageFilter : |
| 37 |
IND |
****public ImageToImageFilter<TInputImage, TOutputImage> |
| 38 |
|
{ |
| 39 |
|
public: |
| 40 |
|
/** Standard class typedefs. */ |
| 41 |
|
typedef DifferenceImageFilter Self; |
| 42 |
TDA |
typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass; |
| 43 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 44 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 45 |
|
|
| 46 |
|
/** Method for creation through the object factory. */ |
| 47 |
|
itkNewMacro(Self); |
| 48 |
|
|
| 49 |
|
/** Run-time type information (and related methods). */ |
| 50 |
|
itkTypeMacro(DifferenceImageFilter, ImageToImageFilter); |
| 51 |
|
|
| 52 |
|
/** Some convenient typedefs. */ |
| 53 |
|
typedef TInputImage InputImageType; |
| 54 |
TDA |
typedef TOutputImage OutputImageType; |
| 55 |
TDA |
typedef typename OutputImageType::PixelType OutputPixelType; |
| 56 |
TDA |
typedef typename OutputImageType::RegionType OutputImageRegionType; |
| 57 |
TDA |
typedef typename NumericTraits<OutputPixelType>::RealType RealType; |
| 58 |
TDA |
typedef typename NumericTraits<RealType>::AccumulateType AccumulateType; |
| 59 |
|
|
| 60 |
|
/** Set the valid image input. This will be input 0. */ |
| 61 |
|
virtual void SetValidInput(const InputImageType* validImage); |
| 62 |
|
|
| 63 |
|
/** Set the test image input. This will be input 1. */ |
| 64 |
|
virtual void SetTestInput(const InputImageType* testImage); |
| 65 |
|
|
| 66 |
|
/** Set/Get the maximum distance away to look for a matching pixel. |
| 67 |
IND |
******Default is 0. */ |
| 68 |
|
itkSetMacro(ToleranceRadius, int); |
| 69 |
|
itkGetMacro(ToleranceRadius, int); |
| 70 |
|
|
| 71 |
|
/** Set/Get the minimum threshold for pixels to be different. |
| 72 |
IND |
******Default is 0. */ |
| 73 |
|
itkSetMacro(DifferenceThreshold, OutputPixelType); |
| 74 |
|
itkGetMacro(DifferenceThreshold, OutputPixelType); |
| 75 |
|
|
| 76 |
|
/** Get parameters of the difference image after execution. */ |
| 77 |
|
itkGetMacro(MeanDifference, RealType); |
| 78 |
|
itkGetMacro(TotalDifference, AccumulateType); |
| 79 |
|
|
| 80 |
|
protected: |
| 81 |
|
DifferenceImageFilter(); |
| 82 |
|
virtual ~DifferenceImageFilter() {} |
| 83 |
|
|
| 84 |
|
void PrintSelf(std::ostream& os, Indent indent) const; |
| 85 |
|
|
| 86 |
|
/** DifferenceImageFilter can be implemented as a multithreaded |
| 87 |
|
* filter. Therefore, this implementation provides a |
| 88 |
|
* ThreadedGenerateData() routine which is called for each |
| 89 |
|
* processing thread. The output image data is allocated |
| 90 |
|
* automatically by the superclass prior to calling |
| 91 |
|
* ThreadedGenerateData(). ThreadedGenerateData can only write to |
| 92 |
|
* the portion of the output image specified by the parameter |
| 93 |
|
* "outputRegionForThread" |
| 94 |
|
* |
| 95 |
|
* \sa ImageToImageFilter::ThreadedGenerateData(), |
| 96 |
|
* ImageToImageFilter::GenerateData() */ |
| 97 |
|
void ThreadedGenerateData(const OutputImageRegionType& threadRegion, |
| 98 |
|
int threadId); |
| 99 |
|
|
| 100 |
|
void BeforeThreadedGenerateData(); |
| 101 |
|
void AfterThreadedGenerateData(); |
| 102 |
|
|
| 103 |
|
OutputPixelType m_DifferenceThreshold; |
| 104 |
|
RealType m_MeanDifference; |
| 105 |
|
AccumulateType m_TotalDifference; |
| 106 |
|
int m_ToleranceRadius; |
| 107 |
|
|
| 108 |
|
Array<AccumulateType> m_ThreadDifferenceSum; |
| 109 |
|
|
| 110 |
|
private: |
| 111 |
|
DifferenceImageFilter(const Self&); //purposely not implemented |
| 112 |
|
void operator=(const Self&); //purposely not implemented |
| 113 |
|
}; |
| 114 |
|
|
| 115 |
|
} // end namespace itk |
| 116 |
|
|
| 117 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 118 |
|
#include "itkDifferenceImageFilter.txx" |
| 119 |
|
#endif |
| 120 |
|
|
| 121 |
|
#endif |
| 122 |
|
|