ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkDiscreteGaussianImageFilter.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 __itkDiscreteGaussianImageFilter_h
00019 #define __itkDiscreteGaussianImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkImage.h"
00023 
00024 namespace itk
00025 {
00061 template< class TInputImage, class TOutputImage >
00062 class ITK_EXPORT DiscreteGaussianImageFilter:
00063   public ImageToImageFilter< TInputImage, TOutputImage >
00064 {
00065 public:
00067   typedef DiscreteGaussianImageFilter                     Self;
00068   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00069   typedef SmartPointer< Self >                            Pointer;
00070   typedef SmartPointer< const Self >                      ConstPointer;
00071 
00073   itkNewMacro(Self);
00074 
00076   itkTypeMacro(DiscreteGaussianImageFilter, ImageToImageFilter);
00077 
00079   typedef TInputImage  InputImageType;
00080   typedef TOutputImage OutputImageType;
00081 
00084   typedef typename TOutputImage::PixelType         OutputPixelType;
00085   typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
00086   typedef typename TInputImage::PixelType          InputPixelType;
00087   typedef typename TInputImage::InternalPixelType  InputInternalPixelType;
00088 
00090   typedef typename NumericTraits<InputPixelType>::ValueType InputPixelValueType;
00091   typedef typename NumericTraits<OutputPixelType>::ValueType OutputPixelValueType;
00092 
00095   itkStaticConstMacro(ImageDimension, unsigned int,
00096                       TOutputImage::ImageDimension);
00097 
00099   typedef FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ArrayType;
00100 
00107   itkSetMacro(Variance, ArrayType);
00108   itkGetConstMacro(Variance, const ArrayType);
00110 
00114   itkSetMacro(MaximumError, ArrayType);
00115   itkGetConstMacro(MaximumError, const ArrayType);
00117 
00120   itkGetConstMacro(MaximumKernelWidth, int);
00121   itkSetMacro(MaximumKernelWidth, int);
00123 
00129   itkGetConstMacro(FilterDimensionality, unsigned int);
00130   itkSetMacro(FilterDimensionality, unsigned int);
00132 
00135   void SetVariance(const typename ArrayType::ValueType v)
00136   {
00137     m_Variance.Fill(v);
00138   }
00139 
00140   void SetMaximumError(const typename ArrayType::ValueType v)
00141   {
00142     m_MaximumError.Fill(v);
00143   }
00144 
00145   void SetVariance(const double *v)
00146   {
00147     ArrayType dv;
00148 
00149     for ( unsigned int i = 0; i < ImageDimension; i++ )
00150       {
00151       dv[i] = v[i];
00152       }
00153     this->SetVariance(dv);
00154   }
00155 
00156   void SetVariance(const float *v)
00157   {
00158     ArrayType dv;
00159 
00160     for ( unsigned int i = 0; i < ImageDimension; i++ )
00161       {
00162       dv[i] = v[i];
00163       }
00164     this->SetVariance(dv);
00165   }
00166 
00167   void SetMaximumError(const double *v)
00168   {
00169     ArrayType dv;
00170 
00171     for ( unsigned int i = 0; i < ImageDimension; i++ )
00172       {
00173       dv[i] = v[i];
00174       }
00175     this->SetMaximumError(dv);
00176   }
00177 
00178   void SetMaximumError(const float *v)
00179   {
00180     ArrayType dv;
00181 
00182     for ( unsigned int i = 0; i < ImageDimension; i++ )
00183       {
00184       dv[i] = v[i];
00185       }
00186     this->SetMaximumError(dv);
00187   }
00188 
00192   void SetUseImageSpacingOn()
00193   { this->SetUseImageSpacing(true); }
00194 
00197   void SetUseImageSpacingOff()
00198   { this->SetUseImageSpacing(false); }
00199 
00202   itkSetMacro(UseImageSpacing, bool);
00203   itkGetConstMacro(UseImageSpacing, bool);
00205 
00215   itkSetMacro(InternalNumberOfStreamDivisions, unsigned int);
00216   itkGetConstReferenceMacro(InternalNumberOfStreamDivisions, unsigned int);
00217 
00224   virtual void GenerateInputRequestedRegion()
00225   throw( InvalidRequestedRegionError );
00226 
00227 #ifdef ITK_USE_CONCEPT_CHECKING
00228 
00230   itkConceptMacro( OutputHasNumericTraitsCheck,
00231                    ( Concept::HasNumericTraits< OutputPixelValueType > ) );
00232 
00234 #endif
00235 protected:
00236   DiscreteGaussianImageFilter()
00237   {
00238     m_Variance.Fill(0.0);
00239     m_MaximumError.Fill(0.01);
00240     m_MaximumKernelWidth = 32;
00241     m_UseImageSpacing = true;
00242     m_FilterDimensionality = ImageDimension;
00243     m_InternalNumberOfStreamDivisions = ImageDimension * ImageDimension;
00244   }
00246 
00247   virtual ~DiscreteGaussianImageFilter() {}
00248   void PrintSelf(std::ostream & os, Indent indent) const;
00249 
00255   void GenerateData();
00256 
00257 private:
00258   DiscreteGaussianImageFilter(const Self &); //purposely not implemented
00259   void operator=(const Self &);              //purposely not implemented
00260 
00263   ArrayType m_Variance;
00264 
00268   ArrayType m_MaximumError;
00269 
00272   int m_MaximumKernelWidth;
00273 
00275   unsigned int m_FilterDimensionality;
00276 
00278   bool m_UseImageSpacing;
00279 
00282   unsigned int m_InternalNumberOfStreamDivisions;
00283 };
00284 } // end namespace itk
00285 
00286 #ifndef ITK_MANUAL_INSTANTIATION
00287 #include "itkDiscreteGaussianImageFilter.hxx"
00288 #endif
00289 
00290 #endif
00291