ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkInverseDeconvolutionImageFilter_h 00019 #define __itkInverseDeconvolutionImageFilter_h 00020 00021 #include "itkFFTConvolutionImageFilter.h" 00022 00023 namespace itk 00024 { 00053 template< class TInputImage, class TKernelImage = TInputImage, class TOutputImage = TInputImage, class TInternalPrecision=double > 00054 class ITK_EXPORT InverseDeconvolutionImageFilter : 00055 public FFTConvolutionImageFilter< TInputImage, TKernelImage, TOutputImage > 00056 { 00057 public: 00058 typedef InverseDeconvolutionImageFilter Self; 00059 typedef FFTConvolutionImageFilter< TInputImage, TOutputImage > Superclass; 00060 typedef SmartPointer< Self > Pointer; 00061 typedef SmartPointer< const Self > ConstPointer; 00062 00064 itkNewMacro(Self); 00065 00067 itkTypeMacro(InverseDeconvolutionImageFilter, FFTConvolutionImageFilter); 00068 00070 itkStaticConstMacro(ImageDimension, unsigned int, 00071 TInputImage::ImageDimension); 00072 00073 typedef TInputImage InputImageType; 00074 typedef TOutputImage OutputImageType; 00075 typedef TKernelImage KernelImageType; 00076 typedef typename Superclass::InputPixelType InputPixelType; 00077 typedef typename Superclass::OutputPixelType OutputPixelType; 00078 typedef typename Superclass::KernelPixelType KernelPixelType; 00079 typedef typename Superclass::InputIndexType InputIndexType; 00080 typedef typename Superclass::OutputIndexType OutputIndexType; 00081 typedef typename Superclass::KernelIndexType KernelIndexType; 00082 typedef typename Superclass::InputSizeType InputSizeType; 00083 typedef typename Superclass::OutputSizeType OutputSizeType; 00084 typedef typename Superclass::KernelSizeType KernelSizeType; 00085 typedef typename Superclass::SizeValueType SizeValueType; 00086 typedef typename Superclass::InputRegionType InputRegionType; 00087 typedef typename Superclass::OutputRegionType OutputRegionType; 00088 typedef typename Superclass::KernelRegionType KernelRegionType; 00089 00091 typedef typename Superclass::InternalImageType InternalImageType; 00092 typedef typename Superclass::InternalImagePointerType InternalImagePointerType; 00093 typedef typename Superclass::InternalComplexType InternalComplexType; 00094 typedef typename Superclass::InternalComplexImageType InternalComplexImageType; 00095 typedef typename Superclass::InternalComplexImagePointerType InternalComplexImagePointerType; 00096 00100 itkSetMacro(KernelZeroMagnitudeThreshold, double); 00101 itkGetConstMacro(KernelZeroMagnitudeThreshold, double); 00103 00104 protected: 00105 InverseDeconvolutionImageFilter(); 00106 ~InverseDeconvolutionImageFilter() {} 00107 00109 void GenerateData(); 00110 00111 virtual void PrintSelf(std::ostream & os, Indent indent) const; 00112 00113 private: 00114 InverseDeconvolutionImageFilter(const Self &); //purposely not implemented 00115 void operator=(const Self &); //purposely not implemented 00116 00117 double m_KernelZeroMagnitudeThreshold; 00118 }; 00119 00120 namespace Functor 00121 { 00122 template< class TInput1, class TInput2, class TOutput > 00123 class InverseDeconvolutionFunctor 00124 { 00125 public: 00126 InverseDeconvolutionFunctor() { m_KernelZeroMagnitudeThreshold = 0.0; } 00127 ~InverseDeconvolutionFunctor() {} 00128 00129 bool operator!=( const InverseDeconvolutionFunctor & ) const 00130 { 00131 return false; 00132 } 00133 bool operator==( const InverseDeconvolutionFunctor & other) const 00134 { 00135 return !(*this != other); 00136 } 00137 inline TOutput operator()(const TInput1 & I, const TInput2 & H) const 00138 { 00139 double absH = std::abs( H ); 00140 TOutput value = NumericTraits< TOutput >::ZeroValue(); 00141 if ( absH >= m_KernelZeroMagnitudeThreshold ) 00142 { 00143 value = static_cast< TOutput >( I / H ); 00144 } 00145 return value; 00146 } 00147 00150 void SetKernelZeroMagnitudeThreshold(double mu) 00151 { 00152 m_KernelZeroMagnitudeThreshold = mu; 00153 } 00154 double GetKernelZeroMagnitudeThreshold() const 00155 { 00156 return m_KernelZeroMagnitudeThreshold; 00157 } 00159 00160 private: 00161 double m_KernelZeroMagnitudeThreshold; 00162 }; 00163 } //namespace Functor 00164 00165 } 00166 00167 #ifndef ITK_MANUAL_INSTANTIATION 00168 #include "itkInverseDeconvolutionImageFilter.hxx" 00169 #endif 00170 00171 #endif 00172