ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkResampleImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkResampleImageFilter_h
19 #define __itkResampleImageFilter_h
20 
21 #include "itkFixedArray.h"
22 #include "itkTransform.h"
23 #include "itkImageRegionIterator.h"
24 #include "itkImageToImageFilter.h"
27 #include "itkSize.h"
29 
30 namespace itk
31 {
83 template< class TInputImage,
84  class TOutputImage,
85  class TInterpolatorPrecisionType = double >
86 class ITK_EXPORT ResampleImageFilter:
87  public ImageToImageFilter< TInputImage, TOutputImage >
88 {
89 public:
95 
96  typedef TInputImage InputImageType;
97  typedef TOutputImage OutputImageType;
98  typedef typename InputImageType::Pointer InputImagePointer;
99  typedef typename InputImageType::ConstPointer InputImageConstPointer;
100  typedef typename OutputImageType::Pointer OutputImagePointer;
101  typedef typename InputImageType::RegionType InputImageRegionType;
102 
104  itkNewMacro(Self);
105 
108 
110  itkStaticConstMacro(ImageDimension, unsigned int,
111  TOutputImage::ImageDimension);
112  itkStaticConstMacro(InputImageDimension, unsigned int,
113  TInputImage::ImageDimension);
115 
118 
122  typedef Transform< TInterpolatorPrecisionType,
123  itkGetStaticConstMacro(ImageDimension),
124  itkGetStaticConstMacro(ImageDimension) > TransformType;
127 
130  TInterpolatorPrecisionType > InterpolatorType;
132 
134 
136 
138 
140  TInterpolatorPrecisionType > LinearInterpolatorType;
141  typedef typename LinearInterpolatorType::Pointer
143 
146  TInterpolatorPrecisionType > ExtrapolatorType;
148 
151 
153  typedef typename TOutputImage::IndexType IndexType;
154 
157  //typedef typename TOutputImage::PointType PointType;
158 
160  typedef typename TOutputImage::PixelType PixelType;
161  typedef typename TInputImage::PixelType InputPixelType;
162 
164 
166 
170 
172  typedef typename TOutputImage::RegionType OutputImageRegionType;
173 
175  typedef typename TOutputImage::SpacingType SpacingType;
176  typedef typename TOutputImage::PointType OriginPointType;
177  typedef typename TOutputImage::DirectionType DirectionType;
178 
186  itkSetConstObjectMacro(Transform, TransformType);
187  itkGetConstObjectMacro(Transform, TransformType);
189 
197  itkSetObjectMacro(Interpolator, InterpolatorType);
198  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
200 
204  itkSetObjectMacro(Extrapolator, ExtrapolatorType);
205  itkGetModifiableObjectMacro(Extrapolator, ExtrapolatorType);
207 
209  itkSetMacro(Size, SizeType);
210  itkGetConstReferenceMacro(Size, SizeType);
212 
215  itkSetMacro(DefaultPixelValue, PixelType);
216  itkGetConstReferenceMacro(DefaultPixelValue, PixelType);
218 
220  itkSetMacro(OutputSpacing, SpacingType);
221  virtual void SetOutputSpacing(const double *values);
223 
225  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
226 
228  itkSetMacro(OutputOrigin, OriginPointType);
229  virtual void SetOutputOrigin(const double *values);
231 
233  itkGetConstReferenceMacro(OutputOrigin, OriginPointType);
234 
236  itkSetMacro(OutputDirection, DirectionType);
237  itkGetConstReferenceMacro(OutputDirection, DirectionType);
239 
241  void SetOutputParametersFromImage(const ImageBaseType *image);
242 
245  itkSetMacro(OutputStartIndex, IndexType);
246 
248  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
249 
255  void SetReferenceImage(const TOutputImage *image);
256 
257  const TOutputImage * GetReferenceImage() const;
258 
259  itkSetMacro(UseReferenceImage, bool);
260  itkBooleanMacro(UseReferenceImage);
261  itkGetConstMacro(UseReferenceImage, bool);
262 
268  virtual void GenerateOutputInformation();
269 
275  virtual void GenerateInputRequestedRegion();
276 
279  virtual void BeforeThreadedGenerateData();
280 
283  virtual void AfterThreadedGenerateData();
284 
286  ModifiedTimeType GetMTime(void) const;
287 
288 #ifdef ITK_USE_CONCEPT_CHECKING
289 
290  itkConceptMacro( OutputHasNumericTraitsCheck,
292 
294 #endif
295 
296 protected:
299  void PrintSelf(std::ostream & os, Indent indent) const;
300 
301 
307  virtual void VerifyInputInformation() {}
308 
318  virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
319  ThreadIdType threadId);
320 
323  virtual void NonlinearThreadedGenerateData(const OutputImageRegionType &
324  outputRegionForThread,
325  ThreadIdType threadId);
326 
330  virtual void LinearThreadedGenerateData(const OutputImageRegionType &
331  outputRegionForThread,
332  ThreadIdType threadId);
333 
334  virtual PixelType CastPixelWithBoundsChecking( const InterpolatorOutputType value,
335  const ComponentType minComponent,
336  const ComponentType maxComponent) const;
337 
338 private:
339  ResampleImageFilter(const Self &); //purposely not implemented
340  void operator=(const Self &); //purposely not implemented
341 
342  SizeType m_Size; // Size of the output image
345  // interpolation
347  // extrapolation
348  PixelType m_DefaultPixelValue; // default pixel value
349  // if the point is
350  // outside the image
351  SpacingType m_OutputSpacing; // output image spacing
352  OriginPointType m_OutputOrigin; // output image origin
353  DirectionType m_OutputDirection; // output image direction cosines
354  IndexType m_OutputStartIndex; // output image start index
356 
357 };
358 } // end namespace itk
359 
360 #ifndef ITK_MANUAL_INSTANTIATION
361 #include "itkResampleImageFilter.hxx"
362 #endif
363 
364 #endif
365