ITK  4.13.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:
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  typedef typename TOutput::ValueType OutputValueType;
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:
85  TInputImage, TOutputImage,
86  Functor::VectorCast< typename TInputImage::PixelType,
87  typename TOutputImage::PixelType > > Superclass;
88 
91 
93  itkNewMacro(Self);
94 
96  itkTypeMacro(VectorCastImageFilter,
98 
99 #ifdef ITK_USE_CONCEPT_CHECKING
100  // Begin concept checking
101  itkConceptMacro( InputHasNumericTraitsCheck,
103  itkConceptMacro( OutputHasNumericTraitsCheck,
105  itkConceptMacro( InputConvertibleToOutputCheck,
106  ( Concept::Convertible< typename TInputImage::PixelType::ValueType,
107  typename TOutputImage::PixelType::ValueType > ) );
108  // End concept checking
109 #endif
110 
111 protected:
113  virtual ~VectorCastImageFilter() ITK_OVERRIDE {}
114 
115 private:
116  ITK_DISALLOW_COPY_AND_ASSIGN(VectorCastImageFilter);
117 };
118 } // end namespace itk
119 
120 #endif
Casts input vector pixels to output vector pixel type.
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::VectorCast< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
bool operator==(const VectorCast &other) const
Base class for all process objects that output image data.
bool operator!=(const VectorCast &) const
SmartPointer< const Self > ConstPointer
Implements pixel-wise generic operation on one image.
#define itkConceptMacro(name, concept)
TOutput operator()(const TInput &A) const