ITK  5.2.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 false;
42  }
44 
45  bool
46  operator==(const Modulus2 & other) const
47  {
48  return !(*this != other);
49  }
50 
51  inline TOutput
52  operator()(const TInput1 & A, const TInput2 & B) const
53  {
54  const auto dA = static_cast<double>(A);
55  const auto dB = static_cast<double>(B);
56 
57  return static_cast<TOutput>(std::sqrt(dA * dA + dB * dB));
58  }
59 };
60 } // namespace Functor
61 
88 template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
89 class BinaryMagnitudeImageFilter : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
90 {
91 public:
92  ITK_DISALLOW_COPY_AND_MOVE(BinaryMagnitudeImageFilter);
93 
99  using FunctorType = Functor::
100  Modulus2<typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType>;
101 
103  itkNewMacro(Self);
104 
107 
108 #ifdef ITK_USE_CONCEPT_CHECKING
109  // Begin concept checking
113  // End concept checking
114 #endif
115 
116 protected:
118  {
119 #if !defined(ITK_WRAPPING_PARSER)
121 #endif
122  }
123 
124  ~BinaryMagnitudeImageFilter() override = default;
125 };
126 } // end namespace itk
127 
128 #endif
itk::BinaryMagnitudeImageFilter
Computes the square root of the sum of squares of corresponding input pixels.
Definition: itkBinaryMagnitudeImageFilter.h:89
itk::Functor::Modulus2::operator==
bool operator==(const Modulus2 &other) const
Definition: itkBinaryMagnitudeImageFilter.h:46
itk::BinaryMagnitudeImageFilter::FunctorType
Functor::Modulus2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkBinaryMagnitudeImageFilter.h:100
itk::BinaryGeneratorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryGeneratorImageFilter.h:56
itk::SmartPointer< Self >
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:117
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::operator!=
bool operator!=(const Modulus2 &) const
Definition: itkBinaryMagnitudeImageFilter.h:39
itk::Functor::Modulus2::~Modulus2
~Modulus2()=default
itk::BinaryMagnitudeImageFilter::~BinaryMagnitudeImageFilter
~BinaryMagnitudeImageFilter() override=default
itk::Functor::Modulus2::Modulus2
Modulus2()=default
itk::BinaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkBinaryGeneratorImageFilter.h:150
itk::Functor::Modulus2::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBinaryMagnitudeImageFilter.h:52