ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVectorCastImageFilter.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 itkVectorCastImageFilter_h
19 #define itkVectorCastImageFilter_h
20 
23 
24 namespace itk
25 {
42 namespace Functor
43 {
44 template< typename TInput, typename TOutput >
46 {
47 public:
48  VectorCast() = default;
49  ~VectorCast() = default;
50  bool operator!=(const VectorCast &) const
51  {
52  return false;
53  }
54 
55  bool operator==(const VectorCast & other) const
56  {
57  return !( *this != other );
58  }
59 
60  inline TOutput operator()(const TInput & A) const
61  {
62  using OutputValueType = typename TOutput::ValueType;
63 
64  TOutput value;
65  for ( unsigned int k = 0; k < TOutput::Dimension; k++ )
66  {
67  value[k] = static_cast< OutputValueType >( A[k] );
68  }
69  return value;
70  }
71 };
72 }
73 
74 template< typename TInputImage, typename TOutputImage >
76  public
77  UnaryFunctorImageFilter< TInputImage, TOutputImage,
78  Functor::VectorCast< typename TInputImage::PixelType,
79  typename TOutputImage::PixelType > >
80 {
81 public:
82  ITK_DISALLOW_COPY_AND_ASSIGN(VectorCastImageFilter);
83 
87  TInputImage, TOutputImage,
88  Functor::VectorCast< typename TInputImage::PixelType,
89  typename TOutputImage::PixelType > >;
90 
93 
95  itkNewMacro(Self);
96 
98  itkTypeMacro(VectorCastImageFilter,
100 
101 #ifdef ITK_USE_CONCEPT_CHECKING
102  // Begin concept checking
103  itkConceptMacro( InputHasNumericTraitsCheck,
105  itkConceptMacro( OutputHasNumericTraitsCheck,
107  itkConceptMacro( InputConvertibleToOutputCheck,
108  ( Concept::Convertible< typename TInputImage::PixelType::ValueType,
109  typename TOutputImage::PixelType::ValueType > ) );
110  // End concept checking
111 #endif
112 
113 protected:
114  VectorCastImageFilter() = default;
115  ~VectorCastImageFilter() override = default;
116 };
117 } // end namespace itk
118 
119 #endif
Casts input vector pixels to output vector pixel type.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
bool operator==(const VectorCast &other) const
Base class for all process objects that output image data.
bool operator!=(const VectorCast &) const
Implements pixel-wise generic operation on one image.
~VectorCastImageFilter() override=default
#define itkConceptMacro(name, concept)
TOutput operator()(const TInput &A) const