ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkPowImageFilter.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 itkPowImageFilter_h
19 #define itkPowImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
33 template< typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1 >
34 class Pow
35 {
36 public:
37 
38  Pow() = default;
39  bool operator!=(const Pow &) const
40  {
41  // we contain no data, so we are always the same
42  return false;
43  }
44 
45  bool operator==(const Pow & other) const
46  {
47  return !( *this != other );
48  }
49 
50  inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
51  {
52 
53  using RealType1 = typename NumericTraits< TInput1 >::RealType;
54  using RealType2 = typename NumericTraits< TInput2 >::RealType;
55  return static_cast< TOutput >( std::pow(static_cast<RealType1>(A),static_cast<RealType2>(B)) );
56  }
57 };
58 }
59 
92 template< typename TInputImage1, typename TInputImage2 = TInputImage1, typename TOutputImage = TInputImage1 >
94  public
95  BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage >
96 
97 {
98 public:
99  ITK_DISALLOW_COPY_AND_ASSIGN(PowImageFilter);
100 
104 
107  using FunctorType = Functor::Pow< typename TInputImage1::PixelType,
108  typename TInputImage2::PixelType,
109  typename TOutputImage::PixelType >;
110 
112  itkNewMacro(Self);
113 
115  itkTypeMacro(PowImageFilter,
117 
118 #ifdef ITK_USE_CONCEPT_CHECKING
119  // Begin concept checking
120  // End concept checking
121 #endif
122 
123 protected:
125  {
126 #if !defined( ITK_WRAPPING_PARSER )
128 #endif
129  }
130 
131  ~PowImageFilter() override = default;
132 };
133 } // end namespace itk
134 
135 #endif
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Define numeric traits for std::vector.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
~PowImageFilter() override=default
Implements pixel-wise generic operation of two images, or of an image and a constant.
Computes the powers of 2 images.
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Functor::Pow< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
bool operator==(const Pow &other) const
bool operator!=(const Pow &) const