ITK  5.4.0
Insight Toolkit
itkCastImageFilter.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 itkCastImageFilter_h
19#define itkCastImageFilter_h
20
22#include "itkProgressReporter.h"
24
25#include <type_traits>
26
27namespace itk
28{
29#if !defined(ITK_LEGACY_REMOVE)
30namespace Functor
31{
38template <typename TInput, typename TOutput>
39class ITK_TEMPLATE_EXPORT Cast
40{
41public:
42 Cast() = default;
43 virtual ~Cast() = default;
44 bool
45 operator==(const Cast &) const
46 {
47 return true;
48 }
49
50 ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Cast);
51
52 inline TOutput
53 operator()(const TInput & A) const
54 {
55 return static_cast<TOutput>(A);
56 }
57};
58} // namespace Functor
59#endif
60
61
99template <typename TInputImage, typename TOutputImage>
100class ITK_TEMPLATE_EXPORT CastImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
101{
102public:
103 ITK_DISALLOW_COPY_AND_MOVE(CastImageFilter);
104
107
109
112
113
114 using typename Superclass::OutputImageRegionType;
115
116 using InputPixelType = typename TInputImage::PixelType;
117 using OutputPixelType = typename TOutputImage::PixelType;
118
120 itkNewMacro(Self);
121
123 itkOverrideGetNameOfClassMacro(CastImageFilter);
124
125protected:
127 ~CastImageFilter() override = default;
128
129 void
131
132 void
133 GenerateData() override;
134
135 void
136 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
137
138 template <typename TInputPixelType,
139 typename TOutputPixelType,
140 std::enable_if_t<mpl::is_static_castable<TInputPixelType, TOutputPixelType>::value, int> = 0>
141 void
143
144 template <typename TInputPixelType,
145 typename TOutputPixelType,
146 std::enable_if_t<!mpl::is_static_castable<TInputPixelType, TOutputPixelType>::value, int> = 0>
147 void
149
150private:
151};
152} // end namespace itk
153
154#ifndef ITK_MANUAL_INSTANTIATION
155# include "itkCastImageFilter.hxx"
156#endif
157
158#endif
Casts input pixels to output pixel type.
void GenerateData() override
void GenerateOutputInformation() override
typename TOutputImage::PixelType OutputPixelType
~CastImageFilter() override=default
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void DynamicThreadedGenerateDataDispatched(const OutputImageRegionType &outputRegionForThread)
typename TInputImage::PixelType InputPixelType
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputImageRegionType
Base class for filters that take an image as input and overwrite that image as the output.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:545