ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkCastImageFilter.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 itkCastImageFilter_h
19 #define itkCastImageFilter_h
20 
22 #include "itkProgressReporter.h"
23 
24 
25 namespace itk
26 {
27 namespace Functor
28 {
35 template< typename TInput, typename TOutput >
36 class Cast
37 {
38 public:
39  Cast() {}
40  virtual ~Cast() {}
41  bool operator!=(const Cast &) const
42  {
43  return false;
44  }
45 
46  bool operator==(const Cast & other) const
47  {
48  return !( *this != other );
49  }
50 
51  inline TOutput operator()(const TInput & A) const
52  {
53  return static_cast< TOutput >( A );
54  }
55 };
56 }
57 
58 
96 template< typename TInputImage, typename TOutputImage >
98  public UnaryFunctorImageFilter< TInputImage, TOutputImage,
99  Functor::Cast<
100  typename TInputImage::PixelType,
101  typename TOutputImage::PixelType > >
102 {
103 public:
106  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
108  typename TInputImage::PixelType,
109  typename TOutputImage::PixelType >
111 
114 
115 
117 
119  itkNewMacro(Self);
120 
123 
124 #ifdef ITK_USE_CONCEPT_CHECKING
125  // Begin concept checking
126  itkConceptMacro( InputConvertibleToOutputCheck,
127  ( Concept::Convertible< typename TInputImage::PixelType,
128  typename TOutputImage::PixelType > ) );
129  // End concept checking
130 #endif
131 
132 protected:
133  CastImageFilter();
134  // virtual ~CastImageFilter() {} default OK
135 
136  void GenerateData() ITK_OVERRIDE;
137 
138  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) ITK_OVERRIDE;
139 
140 private:
141  CastImageFilter(const Self &) ITK_DELETE_FUNCTION;
142  void operator=(const Self &) ITK_DELETE_FUNCTION;
143 };
144 } // end namespace itk
145 
146 #endif
147 
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itkCastImageFilter.hxx"
151 #endif
Light weight base class for most itk classes.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
bool operator==(const Cast &other) const
Superclass::OutputImageRegionType OutputImageRegionType
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
Implements pixel-wise generic operation on one image.
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::Cast< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
OutputImageType::RegionType OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
TOutput operator()(const TInput &A) const
void GenerateData() override
bool operator!=(const Cast &) const
#define itkConceptMacro(name, concept)
Casts input pixels to output pixel type.