00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBilateralImageFilter_h
00018 #define __itkBilateralImageFilter_h
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkImage.h"
00022 #include "itkFixedArray.h"
00023 #include "itkNeighborhoodIterator.h"
00024 #include "itkConstNeighborhoodIterator.h"
00025 #include "itkNeighborhood.h"
00026
00027 namespace itk
00028 {
00068 template <class TInputImage, class TOutputImage >
00069 class ITK_EXPORT BilateralImageFilter :
00070 public ImageToImageFilter< TInputImage, TOutputImage >
00071 {
00072 public:
00074 typedef BilateralImageFilter Self;
00075 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00076 typedef SmartPointer<Self> Pointer;
00077 typedef SmartPointer<const Self> ConstPointer;
00078
00080 itkNewMacro(Self);
00081
00083 itkTypeMacro(BilateralImageFilter, ImageToImageFilter);
00084
00086 typedef TInputImage InputImageType;
00087 typedef TOutputImage OutputImageType;
00088
00090 typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00091
00094 typedef typename TOutputImage::PixelType OutputPixelType;
00095 typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
00096 typedef typename NumericTraits<OutputPixelType>::RealType OutputPixelRealType;
00097 typedef typename TInputImage::PixelType InputPixelType;
00098 typedef typename TInputImage::InternalPixelType InputInternalPixelType;
00099
00102 itkStaticConstMacro(ImageDimension, unsigned int,
00103 TOutputImage::ImageDimension);
00104
00106 typedef FixedArray<double, itkGetStaticConstMacro(ImageDimension)> ArrayType;
00107
00109 typedef ConstNeighborhoodIterator<TInputImage>
00110 NeighborhoodIteratorType ;
00111
00113 typedef
00114 Neighborhood<double, itkGetStaticConstMacro(ImageDimension)> KernelType;
00115 typedef typename KernelType::SizeType SizeType;
00116
00118 typedef typename KernelType::Iterator KernelIteratorType ;
00119 typedef typename KernelType::ConstIterator KernelConstIteratorType ;
00120
00122 typedef
00123 Image<double, itkGetStaticConstMacro(ImageDimension)> GaussianImageType;
00124
00128 itkSetMacro(DomainSigma, ArrayType);
00129 itkGetMacro(DomainSigma, const ArrayType);
00130 itkSetMacro(RangeSigma, double);
00131 itkGetMacro(RangeSigma, double);
00132 itkGetMacro(FilterDimensionality, unsigned int);
00133 itkSetMacro(FilterDimensionality, unsigned int);
00135
00138 void SetDomainSigma(const double v)
00139 {
00140 m_DomainSigma.Fill(v);
00141 }
00142
00148 itkBooleanMacro(AutomaticKernelSize);
00149 itkGetMacro(AutomaticKernelSize, bool);
00150 itkSetMacro(AutomaticKernelSize, bool);
00152
00155 void SetRadius(const unsigned long);
00156 itkSetMacro(Radius, SizeType);
00157 itkGetConstReferenceMacro(Radius, SizeType);
00159
00160
00164 itkSetMacro(NumberOfRangeGaussianSamples, unsigned long);
00165 itkGetMacro(NumberOfRangeGaussianSamples, unsigned long);
00167
00168 #ifdef ITK_USE_CONCEPT_CHECKING
00169
00170 itkConceptMacro(OutputHasNumericTraitsCheck,
00171 (Concept::HasNumericTraits<OutputPixelType>));
00172
00174 #endif
00175
00176 protected:
00179 BilateralImageFilter()
00180 {
00181 m_Radius.Fill(1);
00182 m_AutomaticKernelSize = true;
00183 m_DomainSigma.Fill(4.0);
00184 m_RangeSigma = 50.0;
00185 m_FilterDimensionality = ImageDimension;
00186 m_NumberOfRangeGaussianSamples = 100;
00187 m_DynamicRange = 0.0;
00188 m_DynamicRangeUsed = 0.0;
00189 m_DomainMu = 2.5;
00190 m_RangeMu = 4.0;
00191
00193
00194 }
00195 virtual ~BilateralImageFilter() {}
00196 void PrintSelf(std::ostream& os, Indent indent) const;
00197
00199 void BeforeThreadedGenerateData();
00200
00203 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00204 int threadId);
00205
00212 virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
00213
00214
00215 private:
00216 BilateralImageFilter(const Self&);
00217 void operator=(const Self&);
00218
00221 double m_RangeSigma;
00222
00225 ArrayType m_DomainSigma;
00226
00229 double m_DomainMu;
00230 double m_RangeMu;
00231
00233 unsigned int m_FilterDimensionality;
00234
00236 KernelType m_GaussianKernel;
00237 SizeType m_Radius;
00238 bool m_AutomaticKernelSize;
00239
00241 unsigned long m_NumberOfRangeGaussianSamples;
00242 double m_DynamicRange;
00243 double m_DynamicRangeUsed;
00244 std::vector<double> m_RangeGaussianTable;
00245 };
00246
00247 }
00248
00249 #ifndef ITK_MANUAL_INSTANTIATION
00250 #include "itkBilateralImageFilter.txx"
00251 #endif
00252
00253 #endif
00254