ITK  4.1.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     this->Modified();
00139   }
00141 
00142   void SetMaximumError(const typename ArrayType::ValueType v)
00143   {
00144     m_MaximumError.Fill(v);
00145     this->Modified();
00146   }
00147 
00148   void SetVariance(const double *v)
00149   {
00150     ArrayType dv;
00151 
00152     for ( unsigned int i = 0; i < ImageDimension; i++ )
00153       {
00154       dv[i] = v[i];
00155       }
00156     this->SetVariance(dv);
00157   }
00158 
00159   void SetVariance(const float *v)
00160   {
00161     ArrayType dv;
00162 
00163     for ( unsigned int i = 0; i < ImageDimension; i++ )
00164       {
00165       dv[i] = v[i];
00166       }
00167     this->SetVariance(dv);
00168   }
00169 
00170   void SetMaximumError(const double *v)
00171   {
00172     ArrayType dv;
00173 
00174     for ( unsigned int i = 0; i < ImageDimension; i++ )
00175       {
00176       dv[i] = v[i];
00177       }
00178     this->SetMaximumError(dv);
00179   }
00180 
00181   void SetMaximumError(const float *v)
00182   {
00183     ArrayType dv;
00184 
00185     for ( unsigned int i = 0; i < ImageDimension; i++ )
00186       {
00187       dv[i] = v[i];
00188       }
00189     this->SetMaximumError(dv);
00190   }
00191 
00195   void SetUseImageSpacingOn()
00196   { this->SetUseImageSpacing(true); }
00197 
00200   void SetUseImageSpacingOff()
00201   { this->SetUseImageSpacing(false); }
00202 
00205   itkSetMacro(UseImageSpacing, bool);
00206   itkGetConstMacro(UseImageSpacing, bool);
00208 
00218   itkSetMacro(InternalNumberOfStreamDivisions, unsigned int);
00219   itkGetConstReferenceMacro(InternalNumberOfStreamDivisions, unsigned int);
00220 
00227   virtual void GenerateInputRequestedRegion()
00228   throw( InvalidRequestedRegionError );
00229 
00230 #ifdef ITK_USE_CONCEPT_CHECKING
00231 
00233   itkConceptMacro( OutputHasNumericTraitsCheck,
00234                    ( Concept::HasNumericTraits< OutputPixelValueType > ) );
00235 
00237 #endif
00238 protected:
00239   DiscreteGaussianImageFilter()
00240   {
00241     m_Variance.Fill(0.0);
00242     m_MaximumError.Fill(0.01);
00243     m_MaximumKernelWidth = 32;
00244     m_UseImageSpacing = true;
00245     m_FilterDimensionality = ImageDimension;
00246     m_InternalNumberOfStreamDivisions = ImageDimension * ImageDimension;
00247   }
00249 
00250   virtual ~DiscreteGaussianImageFilter() {}
00251   void PrintSelf(std::ostream & os, Indent indent) const;
00252 
00258   void GenerateData();
00259 
00260 private:
00261   DiscreteGaussianImageFilter(const Self &); //purposely not implemented
00262   void operator=(const Self &);              //purposely not implemented
00263 
00266   ArrayType m_Variance;
00267 
00271   ArrayType m_MaximumError;
00272 
00275   int m_MaximumKernelWidth;
00276 
00278   unsigned int m_FilterDimensionality;
00279 
00281   bool m_UseImageSpacing;
00282 
00285   unsigned int m_InternalNumberOfStreamDivisions;
00286 };
00287 } // end namespace itk
00288 
00289 #ifndef ITK_MANUAL_INSTANTIATION
00290 #include "itkDiscreteGaussianImageFilter.hxx"
00291 #endif
00292 
00293 #endif
00294