ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAbsImageFilter.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 itkAbsImageFilter_h
19 #define itkAbsImageFilter_h
20 
22 #include "itkConceptChecking.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
32 template< typename TInput, typename TOutput >
33 class Abs
34 {
35 public:
36  Abs() = default;
37  ~Abs() = default;
38  bool operator!=(const Abs &) const
39  {
40  return false;
41  }
42 
43  bool operator==(const Abs & other) const
44  {
45  return !( *this != other );
46  }
47 
48  inline TOutput operator()(const TInput & A) const
49  {
50  return static_cast<TOutput>( itk::Math::abs( A ) );
51  }
52 };
53 }
54 
68 template< typename TInputImage, typename TOutputImage >
70  public
71  UnaryGeneratorImageFilter< TInputImage, TOutputImage >
72 {
73 public:
74  ITK_DISALLOW_COPY_AND_ASSIGN(AbsImageFilter);
75 
81  using FunctorType = Functor::Abs< typename TInputImage::PixelType,
82  typename TOutputImage::PixelType >;
83 
85  itkNewMacro(Self);
86 
89 
90  using InputPixelType = typename TInputImage::PixelType;
91  using OutputPixelType = typename TOutputImage::PixelType;
92 
93 
94 #ifdef ITK_USE_CONCEPT_CHECKING
95  // Begin concept checking
96  itkConceptMacro( ConvertibleCheck,
98  itkConceptMacro( InputGreaterThanIntCheck,
100  // End concept checking
101 #endif
102 
103 protected:
104 
106  {
107 #if !defined( ITK_WRAPPING_PARSER )
109 #endif
110  }
111 
112  ~AbsImageFilter() override = default;
113 };
114 } // end namespace itk
115 
116 #endif
Functor::Abs< typename TInputImage::PixelType, typename TOutputImage::PixelType > FunctorType
bool operator==(const Abs &other) const
TOutput operator()(const TInput &A) const
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.
void SetFunctor(const std::function< ConstRefFunctionType > &f)
bool operator!=(const Abs &) const
typename TInputImage::PixelType InputPixelType
~AbsImageFilter() override=default
typename TOutputImage::PixelType OutputPixelType
Computes the absolute value of each pixel.
Computes the absolute value of a pixel.
#define itkConceptMacro(name, concept)
Implements pixel-wise generic &quot;operation&quot; on one image.