ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkBinShrinkImageFilter.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 itkBinShrinkImageFilter_h
19 #define itkBinShrinkImageFilter_h
20 
21 #include "itkShrinkImageFilter.h"
22 #include <type_traits>
23 
24 namespace itk
25 {
26 
56 template <typename TInputImage, typename TOutputImage>
57 class ITK_TEMPLATE_EXPORT BinShrinkImageFilter :
58  public ImageToImageFilter<TInputImage,TOutputImage>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_ASSIGN(BinShrinkImageFilter);
62 
68 
70  itkNewMacro(Self);
71 
74 
76  using OutputImageType = TOutputImage;
77  using InputImageType = TInputImage;
78  using OutputImagePointer = typename OutputImageType::Pointer;
79  using InputImagePointer = typename InputImageType::Pointer;
80  using InputImageConstPointer = typename InputImageType::ConstPointer;
81 
82  using OutputOffsetType = typename TOutputImage::OffsetType;
85 
88 
90  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
91  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
92 
94 
97  itkSetMacro(ShrinkFactors, ShrinkFactorsType);
98  void SetShrinkFactors(unsigned int factor);
99  void SetShrinkFactor(unsigned int i, unsigned int factor);
101 
103  itkGetConstReferenceMacro(ShrinkFactors, ShrinkFactorsType);
104 
105  void GenerateOutputInformation() override;
106 
112  void GenerateInputRequestedRegion() override;
113 
114 
115 #ifdef ITK_USE_CONCEPT_CHECKING
116 
117  itkConceptMacro(InputConvertibleToOutputCheck,
119  itkConceptMacro(SameDimensionCheck,
121 
123 #endif
124 
125 protected:
127  void PrintSelf(std::ostream & os, Indent indent) const override;
128 
129  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
130 
131 private:
133 
135  template< class TOutputType, class TInputType >
136  typename std::enable_if<std::numeric_limits<TOutputType>::is_integer, TOutputType>::type
137  RoundIfInteger( TInputType input )
138  {
139  return Math::Round< TOutputType >( input );
140  }
141 
142  // For Non-fundamental types numeric_limits is not specialized, and
143  // is_integer defaults to false.
144  template< class TOutputType, class TInputType >
145  typename std::enable_if<!std::numeric_limits<TOutputType>::is_integer, TOutputType>::type
146  RoundIfInteger( const TInputType & input, ...)
147  {
148  return static_cast<TOutputType>(input);
149  }
150 };
151 
152 } // end namespace itk
153 
154 #ifndef ITK_MANUAL_INSTANTIATION
155 #include "itkBinShrinkImageFilter.hxx"
156 #endif
157 
158 #endif
typename TOutputImage::IndexType OutputIndexType
typename TInputImage::IndexType InputIndexType
typename OutputImageType::Pointer OutputImagePointer
std::enable_if<!std::numeric_limits< TOutputType >::is_integer, TOutputType >::type RoundIfInteger(const TInputType &input,...)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
Reduce the size of an image by an integer factor in each dimension while performing averaging of an i...
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::enable_if< std::numeric_limits< TOutputType >::is_integer, TOutputType >::type RoundIfInteger(TInputType input)
#define itkConceptMacro(name, concept)
typename InputImageType::ConstPointer InputImageConstPointer
typename TOutputImage::OffsetType OutputOffsetType