ITK  5.2.0
Insight Toolkit
itkBinShrinkImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 
57 template <typename TInputImage, typename TOutputImage>
58 class ITK_TEMPLATE_EXPORT BinShrinkImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_MOVE(BinShrinkImageFilter);
63 
69 
71  itkNewMacro(Self);
72 
75 
77  using OutputImageType = TOutputImage;
78  using InputImageType = TInputImage;
79  using OutputImagePointer = typename OutputImageType::Pointer;
80  using InputImagePointer = typename InputImageType::Pointer;
81  using InputImageConstPointer = typename InputImageType::ConstPointer;
82 
83  using OutputOffsetType = typename TOutputImage::OffsetType;
86 
89 
91  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
92  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
93 
95 
98  itkSetMacro(ShrinkFactors, ShrinkFactorsType);
99  void
100  SetShrinkFactors(unsigned int factor);
101  void
102  SetShrinkFactor(unsigned int i, unsigned int factor);
104 
106  itkGetConstReferenceMacro(ShrinkFactors, ShrinkFactorsType);
107 
108  void
109  GenerateOutputInformation() override;
110 
116  void
117  GenerateInputRequestedRegion() override;
118 
119 
120 #ifdef ITK_USE_CONCEPT_CHECKING
121 
122  itkConceptMacro(InputConvertibleToOutputCheck,
125 
127 #endif
128 
129 protected:
131  void
132  PrintSelf(std::ostream & os, Indent indent) const override;
133 
134  void
135  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
136 
137 private:
139 
141  template <class TOutputType, class TInputType>
142  typename std::enable_if<std::numeric_limits<TOutputType>::is_integer, TOutputType>::type
143  RoundIfInteger(TInputType input)
144  {
145  return Math::Round<TOutputType>(input);
146  }
147 
148  // For Non-fundamental types numeric_limits is not specialized, and
149  // is_integer defaults to false.
150  template <class TOutputType, class TInputType>
151  typename std::enable_if<!std::numeric_limits<TOutputType>::is_integer, TOutputType>::type
152  RoundIfInteger(const TInputType & input, ...)
153  {
154  return static_cast<TOutputType>(input);
155  }
156 };
157 
158 } // end namespace itk
159 
160 #ifndef ITK_MANUAL_INSTANTIATION
161 # include "itkBinShrinkImageFilter.hxx"
162 #endif
163 
164 #endif
itk::BinShrinkImageFilter::OutputOffsetType
typename TOutputImage::OffsetType OutputOffsetType
Definition: itkBinShrinkImageFilter.h:83
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::BinShrinkImageFilter::RoundIfInteger
std::enable_if< std::numeric_limits< TOutputType >::is_integer, TOutputType >::type RoundIfInteger(TInputType input)
Definition: itkBinShrinkImageFilter.h:143
itk::BinShrinkImageFilter
Reduce the size of an image by an integer factor in each dimension while performing averaging of an i...
Definition: itkBinShrinkImageFilter.h:58
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BinShrinkImageFilter::m_ShrinkFactors
ShrinkFactorsType m_ShrinkFactors
Definition: itkBinShrinkImageFilter.h:138
itk::Concept::SameDimension
Definition: itkConceptChecking.h:694
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::FixedArray< unsigned int, ImageDimension >
itk::BinShrinkImageFilter::RoundIfInteger
std::enable_if<!std::numeric_limits< TOutputType >::is_integer, TOutputType >::type RoundIfInteger(const TInputType &input,...)
Definition: itkBinShrinkImageFilter.h:152
itk::BinShrinkImageFilter::OutputIndexType
typename TOutputImage::IndexType OutputIndexType
Definition: itkBinShrinkImageFilter.h:84
itkShrinkImageFilter.h
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::BinShrinkImageFilter::InputIndexType
typename TInputImage::IndexType InputIndexType
Definition: itkBinShrinkImageFilter.h:85
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::ImageToImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkImageToImageFilter.h:131
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90