ITK  5.3.0
Insight Toolkit
itkBinaryMagnitudeImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 itkBinaryMagnitudeImageFilter_h
19 #define itkBinaryMagnitudeImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
32 template <typename TInput1, typename TInput2, typename TOutput>
33 class Modulus2
34 {
35 public:
36  Modulus2() = default;
37  ~Modulus2() = default;
38  bool
39  operator==(const Modulus2 &) const
40  {
41  return true;
42  }
44 
46 
47  inline TOutput
48  operator()(const TInput1 & A, const TInput2 & B) const
49  {
50  const auto dA = static_cast<double>(A);
51  const auto dB = static_cast<double>(B);
52 
53  return static_cast<TOutput>(std::sqrt(dA * dA + dB * dB));
54  }
55 };
56 } // namespace Functor
57 
84 template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
85 class ITK_TEMPLATE_EXPORT BinaryMagnitudeImageFilter
86  : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
87 {
88 public:
89  ITK_DISALLOW_COPY_AND_MOVE(BinaryMagnitudeImageFilter);
90 
96  using FunctorType = Functor::
97  Modulus2<typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType>;
98 
100  itkNewMacro(Self);
101 
104 
105 #ifdef ITK_USE_CONCEPT_CHECKING
106  // Begin concept checking
110  // End concept checking
111 #endif
112 
113 protected:
115  {
116 #if !defined(ITK_WRAPPING_PARSER)
117  Superclass::SetFunctor(FunctorType());
118 #endif
119  }
120 
121  ~BinaryMagnitudeImageFilter() override = default;
122 };
123 } // end namespace itk
124 
125 #endif
itk::BinaryMagnitudeImageFilter
Computes the square root of the sum of squares of corresponding input pixels.
Definition: itkBinaryMagnitudeImageFilter.h:85
itk::Functor::Modulus2::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Modulus2)
itk::BinaryGeneratorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryGeneratorImageFilter.h:56
itk::SmartPointer< Self >
itk::Functor::Modulus2::operator==
bool operator==(const Modulus2 &) const
Definition: itkBinaryMagnitudeImageFilter.h:39
itkBinaryGeneratorImageFilter.h
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::BinaryMagnitudeImageFilter::BinaryMagnitudeImageFilter
BinaryMagnitudeImageFilter()
Definition: itkBinaryMagnitudeImageFilter.h:114
itk::Functor::Modulus2
Definition: itkBinaryMagnitudeImageFilter.h:33
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::Functor::Modulus2::~Modulus2
~Modulus2()=default
itk::Functor::Modulus2::Modulus2
Modulus2()=default
itk::Functor::Modulus2::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBinaryMagnitudeImageFilter.h:48