ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGradientImageFilter.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 __itkGradientImageFilter_h
00019 #define __itkGradientImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkCovariantVector.h"
00023 
00024 namespace itk
00025 {
00048 template< class TInputImage, class TOperatorValueType = float, class TOutputValueType = float >
00049 class ITK_EXPORT GradientImageFilter:
00050   public ImageToImageFilter< TInputImage,
00051                              Image< CovariantVector< TOutputValueType,
00052                                                      ::itk::GetImageDimension< TInputImage >::ImageDimension >,
00053                                     ::itk::GetImageDimension< TInputImage >::ImageDimension > >
00054 {
00055 public:
00057   itkStaticConstMacro(InputImageDimension, unsigned int,
00058                       TInputImage::ImageDimension);
00059   itkStaticConstMacro(OutputImageDimension, unsigned int,
00060                       TInputImage::ImageDimension);
00062 
00064   typedef GradientImageFilter Self;
00065 
00067   typedef TInputImage                      InputImageType;
00068   typedef typename InputImageType::Pointer InputImagePointer;
00069   typedef Image< CovariantVector<
00070                    TOutputValueType, itkGetStaticConstMacro(OutputImageDimension) >,
00071                  itkGetStaticConstMacro(OutputImageDimension) >
00072   OutputImageType;
00073   typedef typename OutputImageType::Pointer OutputImagePointer;
00075 
00077   typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
00078   typedef SmartPointer< Self >                                  Pointer;
00079   typedef SmartPointer< const Self >                            ConstPointer;
00080 
00082   itkNewMacro(Self);
00083 
00085   itkTypeMacro(GradientImageFilter, ImageToImageFilter);
00086 
00088   typedef typename InputImageType::PixelType InputPixelType;
00089   typedef TOperatorValueType                 OperatorValueType;
00090   typedef TOutputValueType                   OutputValueType;
00091   typedef CovariantVector<
00092     OutputValueType, itkGetStaticConstMacro(OutputImageDimension) >
00093   OutputPixelType;
00094   typedef typename OutputImageType::RegionType OutputImageRegionType;
00095 
00102   virtual void GenerateInputRequestedRegion()
00103   throw( InvalidRequestedRegionError );
00104 
00107   void SetUseImageSpacingOn()
00108   { this->SetUseImageSpacing(true); }
00109 
00112   void SetUseImageSpacingOff()
00113   { this->SetUseImageSpacing(false); }
00114 
00117   itkSetMacro(UseImageSpacing, bool);
00118   itkGetConstMacro(UseImageSpacing, bool);
00120 
00121 #ifdef ITK_USE_CONCEPT_CHECKING
00122 
00123   itkConceptMacro( InputConvertibleToOutputCheck,
00124                    ( Concept::Convertible< InputPixelType, OutputValueType > ) );
00125   itkConceptMacro( OutputHasNumericTraitsCheck,
00126                    ( Concept::HasNumericTraits< OutputValueType > ) );
00127 
00129 #endif
00130 
00141   itkSetMacro(UseImageDirection, bool);
00142   itkGetConstMacro(UseImageDirection, bool);
00143   itkBooleanMacro(UseImageDirection);
00144 protected:
00145   GradientImageFilter();
00146   virtual ~GradientImageFilter();
00147   void PrintSelf(std::ostream & os, Indent indent) const;
00149 
00160   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00161                             ThreadIdType threadId);
00162 
00163 private:
00164   GradientImageFilter(const Self &); //purposely not implemented
00165   void operator=(const Self &);      //purposely not implemented
00166 
00167   bool m_UseImageSpacing;
00168 
00169   // flag to take or not the image direction into account
00170   // when computing the derivatives.
00171   bool m_UseImageDirection;
00172 };
00173 } // end namespace itk
00174 
00175 #ifndef ITK_MANUAL_INSTANTIATION
00176 #include "itkGradientImageFilter.hxx"
00177 #endif
00178 
00179 #endif
00180