RTK  2.6.0
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  * https://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_TEMPLATE_EXPORT DownsampleImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
39 {
40 public:
41  ITK_DISALLOW_COPY_AND_MOVE(DownsampleImageFilter);
42 
48 
50  itkNewMacro(Self);
51 
53 #ifdef itkOverrideGetNameOfClassMacro
54  itkOverrideGetNameOfClassMacro(DownsampleImageFilter);
55 #else
57 #endif
58 
59 
61  using OutputImageType = TOutputImage;
62  using InputImageType = TInputImage;
63  using OutputImagePointer = typename OutputImageType::Pointer;
64  using InputImagePointer = typename InputImageType::Pointer;
65  using InputImageConstPointer = typename InputImageType::ConstPointer;
66 
68  using OutputImageRegionType = typename TOutputImage::RegionType;
69 
71  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
72 
75  void
76  SetFactors(const unsigned int factors[]);
77 
80  void
81  SetFactor(unsigned int dimension, unsigned int factor);
82 
90  void
91  GenerateOutputInformation() override;
92 
98  void
99  GenerateInputRequestedRegion() override;
100 
101 protected:
103  ~DownsampleImageFilter() override = default;
104 
115  void
116  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
117 
118 private:
119  unsigned int m_Factors[ImageDimension];
120  int m_Offsets[ImageDimension];
121 };
122 
123 
124 } // end namespace rtk
125 
126 #ifndef rtk_MANUAL_INSTANTIATION
127 # include "rtkDownsampleImageFilter.hxx"
128 #endif
129 
130 #endif
typename OutputImageType::Pointer OutputImagePointer
TInputImage InputImageType
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename InputImageType::ConstPointer InputImageConstPointer
Downsamples an image by a factor in each dimension.