ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkConstrainedValueDifferenceImageFilter.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 itkConstrainedValueDifferenceImageFilter_h
19 #define itkConstrainedValueDifferenceImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
55 namespace Functor
56 {
57 template< typename TInput1, typename TInput2, typename TOutput >
59 {
60 public:
61  ConstrainedValueDifference() = default;
62  ~ConstrainedValueDifference() = default;
64  {
65  return false;
66  }
67 
68  bool operator==(const ConstrainedValueDifference & other) const
69  {
70  return !( *this != other );
71  }
72 
73  inline TOutput operator()(const TInput1 & A,
74  const TInput2 & B) const
75  {
76  const auto dA = static_cast< double >( A );
77  const auto dB = static_cast< double >( B );
78  const double diff = dA - dB;
79  const double cdiff1 = diff > NumericTraits< TOutput >::NonpositiveMin() ?
81  const double cdiff2 = cdiff1 < NumericTraits< TOutput >::max() ?
83 
84  return static_cast< TOutput >( cdiff2 );
85  }
86 };
87 }
88 
89 template< typename TInputImage1, typename TInputImage2, typename TOutputImage >
91  public
92  BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage >
93 {
94 public:
95  ITK_DISALLOW_COPY_AND_ASSIGN(ConstrainedValueDifferenceImageFilter);
96 
102  using FunctorType = Functor::ConstrainedValueDifference< typename TInputImage1::PixelType,
103  typename TInputImage2::PixelType,
104  typename TOutputImage::PixelType >;
105 
107  itkNewMacro(Self);
108 
112 
113 #ifdef ITK_USE_CONCEPT_CHECKING
114  // Begin concept checking
115  itkConceptMacro( Input1ConvertibleToDoubleCheck,
117  itkConceptMacro( Input2ConvertibleToDoubleCheck,
119  itkConceptMacro( DoubleConvertibleToOutputCheck,
121  itkConceptMacro( DoubleGreaterThanOutputCheck,
123  // End concept checking
124 #endif
125 
126 protected:
128  {
129 #if !defined( ITK_WRAPPING_PARSER )
131 #endif
132  }
133 
134  ~ConstrainedValueDifferenceImageFilter() override = default;
135 };
136 } // end namespace itk
137 
138 #endif
Define numeric traits for std::vector.
Functor::ConstrainedValueDifference< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
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.
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Implements pixel-wise the computation of constrained value difference.
bool operator!=(const ConstrainedValueDifference &) const
Implements pixel-wise generic operation of two images, or of an image and a constant.
void SetFunctor(const std::function< ConstRefFunctionType > &f)
#define itkConceptMacro(name, concept)
~ConstrainedValueDifferenceImageFilter() override=default
bool operator==(const ConstrainedValueDifference &other) const