ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkSharpenOpImageFilter.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 * https://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 itkSharpenOpImageFilter_h
19#define itkSharpenOpImageFilter_h
20
22
23namespace itk
24{
46namespace Function
47{
48template <typename TInput1, typename TInput2, typename TInput3, typename TOutput>
49class SharpM
50{
51public:
52 SharpM() = default;
53 ~SharpM() = default;
54 bool
55 operator!=(const SharpM &) const
56 {
57 return false;
58 }
59
60 bool
61 operator==(const SharpM & other) const
62 {
63 return !(*this != other);
64 }
65
66 TOutput
67 operator()(const TInput1 & A, const TInput2 & B, const TInput3 & C)
68 {
69 // the sharpening operator. A is the dilation, B the original, C
70 // the erosion
71 TInput2 diff1 = A - B;
72 TInput2 diff2 = B - C;
73
74 if (diff1 < diff2)
75 {
76 return (TOutput)A;
77 }
78 if (diff2 < diff1)
79 {
80 return (TOutput)C;
81 }
82 return ((TOutput)B);
83 }
84};
85} // namespace Function
86
87template <class TInputImage1, class TInputImage2, class TInputImage3, class TOutputImage>
88class ITK_TEMPLATE_EXPORT SharpenOpImageFilter
89 : public TernaryFunctorImageFilter<TInputImage1,
90 TInputImage2,
91 TInputImage3,
92 TOutputImage,
93 Function::SharpM<typename TInputImage1::PixelType,
94 typename TInputImage2::PixelType,
95 typename TInputImage3::PixelType,
96 typename TOutputImage::PixelType>>
97{
98public:
99 ITK_DISALLOW_COPY_AND_MOVE(SharpenOpImageFilter);
100
104 TInputImage2,
105 TInputImage3,
106 TOutputImage,
107 Function::SharpM<typename TInputImage1::PixelType,
108 typename TInputImage2::PixelType,
109 typename TInputImage3::PixelType,
110 typename TOutputImage::PixelType>>;
113
115 itkNewMacro(Self);
116
118 itkOverrideGetNameOfClassMacro(SharpenOpImageFilter);
119
120protected:
122 ~SharpenOpImageFilter() override = default;
123};
124} // end namespace itk
125
126#endif
bool operator!=(const SharpM &) const
bool operator==(const SharpM &other) const
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C)
TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage, Function::SharpM< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TInputImage3::PixelType, typename TOutputImage::PixelType > > Superclass
~SharpenOpImageFilter() override=default
SmartPointer< const Self > ConstPointer
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....