ITK  6.0.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 * 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#ifndef itkBinShrinkImageFilter_h
19#define itkBinShrinkImageFilter_h
20
22#include <type_traits>
23
24namespace itk
25{
26
57template <typename TInputImage, typename TOutputImage>
58class ITK_TEMPLATE_EXPORT BinShrinkImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
59{
60public:
61 ITK_DISALLOW_COPY_AND_MOVE(BinShrinkImageFilter);
69
71 itkNewMacro(Self);
72
74 itkOverrideGetNameOfClassMacro(BinShrinkImageFilter);
75
77 using OutputImageType = TOutputImage;
78 using InputImageType = TInputImage;
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);
106 itkGetConstReferenceMacro(ShrinkFactors, ShrinkFactorsType);
107
108 void
110
116 void
118
119
120#ifdef ITK_USE_CONCEPT_CHECKING
122 itkConceptMacro(InputConvertibleToOutputCheck,
125
127#endif
128
129protected:
131 void
132 PrintSelf(std::ostream & os, Indent indent) const override;
133
134 void
135 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
136
137private:
138 ShrinkFactorsType m_ShrinkFactors{};
139
141 template <class TOutputType, class TInputType>
142 std::enable_if_t<std::numeric_limits<TOutputType>::is_integer, TOutputType>
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 std::enable_if_t<!std::numeric_limits<TOutputType>::is_integer, TOutputType>
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
Reduce the size of an image by an integer factor in each dimension while performing averaging of an i...
void GenerateOutputInformation() override
void SetShrinkFactors(unsigned int factor)
typename TInputImage::IndexType InputIndexType
typename TOutputImage::OffsetType OutputOffsetType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void PrintSelf(std::ostream &os, Indent indent) const override
std::enable_if_t< std::numeric_limits< TOutputType >::is_integer, TOutputType > RoundIfInteger(TInputType input)
void GenerateInputRequestedRegion() override
typename TOutputImage::IndexType OutputIndexType
void SetShrinkFactor(unsigned int i, unsigned int factor)
std::enable_if_t<!std::numeric_limits< TOutputType >::is_integer, TOutputType > RoundIfInteger(const TInputType &input,...)
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
Base class for filters that take an image as input and produce an image as output.
typename InputImageType::ConstPointer InputImageConstPointer
typename InputImageType::Pointer InputImagePointer
Control indentation during Print() invocation.
Definition: itkIndent.h:50
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....