RTK  2.0.1
Reconstruction Toolkit
rtkDownsampleImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK 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 
19 #ifndef rtkDownsampleImageFilter_h
20 #define rtkDownsampleImageFilter_h
21 
22 #include "itkImageToImageFilter.h"
23 
24 namespace rtk
25 {
26 
37 template <class TInputImage, class TOutputImage = TInputImage>
38 class ITK_EXPORT DownsampleImageFilter:
39  public itk::ImageToImageFilter<TInputImage,TOutputImage>
40 {
41 public:
42  ITK_DISALLOW_COPY_AND_ASSIGN(DownsampleImageFilter);
43 
49 
51  itkNewMacro(Self);
52 
55 
57  using OutputImageType = TOutputImage;
58  using InputImageType = TInputImage;
59  using OutputImagePointer = typename OutputImageType::Pointer;
60  using InputImagePointer = typename InputImageType::Pointer;
61  using InputImageConstPointer = typename InputImageType::ConstPointer;
62 
64  using OutputImageRegionType = typename TOutputImage::RegionType;
65 
67  itkStaticConstMacro(ImageDimension, unsigned int,
68  TInputImage::ImageDimension );
69 
72  void SetFactors(unsigned int factors[]);
73 
76  void SetFactor(unsigned int dimension, unsigned int factor);
77 
85  void GenerateOutputInformation() override;
86 
92  void GenerateInputRequestedRegion() override;
93 
94 protected:
96  ~DownsampleImageFilter() override = default;
97 
108 // virtual void BeforeThreadedGenerateData();
109 #if ITK_VERSION_MAJOR<5
110  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType itkNotUsed(threadId)) override;
111 #else
112  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
113 #endif
114 // virtual void AfterThreadedGenerateData();
116 
117 private:
118  unsigned int m_Factors[ImageDimension];
119  int m_Offsets[ImageDimension];
120 };
121 
122 
123 } // end namespace rtk
124 
125 #ifndef rtk_MANUAL_INSTANTIATION
126 #include "rtkDownsampleImageFilter.hxx"
127 #endif
128 
129 #endif
typename InputImageType::Pointer InputImagePointer
typename InputImageType::ConstPointer InputImageConstPointer
unsigned int ThreadIdType
Downsamples an image by a factor in each dimension.
typename TOutputImage::RegionType OutputImageRegionType
typename OutputImageType::Pointer OutputImagePointer