ITK  4.13.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:
94  typedef TernaryFunctorImageFilter< TInputImage1, TInputImage2,
95  TInputImage3, TOutputImage,
96  Function::SharpM< typename TInputImage1::PixelType,
97  typename TInputImage2::PixelType,
98  typename TInputImage3::PixelType,
99  typename TOutputImage::PixelType > > Superclass;
102 
104  itkNewMacro(Self);
105 
107  itkTypeMacro(SharpenOpImageFilter,
109 protected:
112 private:
113  ITK_DISALLOW_COPY_AND_ASSIGN(SharpenOpImageFilter);
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
SmartPointer< const Self > ConstPointer
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C)
Implements pixel-wise generic operation of three images.
Base class for all process objects that output image data.
TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage, Function::SharpM< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TInputImage3::PixelType, typename TOutputImage::PixelType > > Superclass