ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSharpenOpImageFilter.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 itkSharpenOpImageFilter_h
19 #define itkSharpenOpImageFilter_h
20 
22 
23 namespace itk
24 {
46 namespace Function
47 {
48 template< class TInput1, class TInput2, class TInput3, class TOutput >
49 class SharpM
50 {
51 public:
52  SharpM() {}
53  ~SharpM() {}
54  bool operator!=(const SharpM &) const
55  {
56  return false;
57  }
58 
59  bool operator==(const SharpM & other) const
60  {
61  return !( *this != other );
62  }
63 
64  inline TOutput operator()(const TInput1 & A,
65  const TInput2 & B,
66  const TInput3 & C)
67  {
68  // the sharpening operator. A is the dilation, B the original, C
69  // the erosion
70  TInput2 diff1 = A - B;
71  TInput2 diff2 = B - C;
72 
73  if ( diff1 < diff2 ) { return (TOutput)A; }
74  if ( diff2 < diff1 ) { return (TOutput)C; }
75  return ( (TOutput)B );
76  }
77 };
78 }
79 
80 template< class TInputImage1, class TInputImage2,
81  class TInputImage3, class TOutputImage >
82 class ITK_EXPORT SharpenOpImageFilter:
83  public
84  TernaryFunctorImageFilter< TInputImage1, TInputImage2,
85  TInputImage3, TOutputImage,
86  Function::SharpM< typename TInputImage1::PixelType,
87  typename TInputImage2::PixelType,
88  typename TInputImage3::PixelType,
89  typename TOutputImage::PixelType > >
90 {
91 public:
92  ITK_DISALLOW_COPY_AND_ASSIGN(SharpenOpImageFilter);
93 
96  using Superclass = TernaryFunctorImageFilter< TInputImage1, TInputImage2,
97  TInputImage3, TOutputImage,
98  Function::SharpM< typename TInputImage1::PixelType,
99  typename TInputImage2::PixelType,
100  typename TInputImage3::PixelType,
101  typename TOutputImage::PixelType > >;
104 
106  itkNewMacro(Self);
107 
109  itkTypeMacro(SharpenOpImageFilter,
111 protected:
113  ~SharpenOpImageFilter() override {}
114 };
115 } // end namespace itk
117 
118 #endif
bool operator!=(const SharpM &) const
Implements the sharpening operation. The inputs are the dilated, eroded and original images...
bool operator==(const SharpM &other) const
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements pixel-wise generic operation of three images.
Base class for all process objects that output image data.