OTB  9.0.0
Orfeo Toolbox
otbMRFEnergyEdgeFidelity.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 
22 #ifndef otbMRFEnergyEdgeFidelity_h
23 #define otbMRFEnergyEdgeFidelity_h
24 
25 #include "otbMRFEnergy.h"
26 
27 namespace otb
28 {
49 
50 template <class TInput1, class TInput2>
51 class ITK_EXPORT MRFEnergyEdgeFidelity : public MRFEnergy<TInput1, TInput2>
52 {
53 public:
56  typedef itk::SmartPointer<Self> Pointer;
57  typedef itk::SmartPointer<const Self> ConstPointer;
58 
59  typedef itk::ConstNeighborhoodIterator<TInput1> NeighborhoodIterator;
60  typedef typename TInput1::PixelType InputImagePixelType;
61  typedef typename TInput2::PixelType LabelledImagePixelType;
62 
63  itkNewMacro(Self);
64 
65  itkTypeMacro(MRFEnergyEdgeFidelity, MRFEnergy);
66 
67  double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) override
68  {
69  double val1 = static_cast<double>(value1);
70  double val2 = static_cast<double>(value2);
71 
72  return vnl_math_sqr((val1 - val2)) / (1 + vnl_math_sqr(val1 - val2));
73  }
74 
75 protected:
76  // The constructor and destructor.
79  {
80  }
81 };
82 }
83 
84 #endif
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MRFEnergyEdgeFidelity::~MRFEnergyEdgeFidelity
~MRFEnergyEdgeFidelity() override
Definition: otbMRFEnergyEdgeFidelity.h:78
otb::MRFEnergyEdgeFidelity::InputImagePixelType
TInput1::PixelType InputImagePixelType
Definition: otbMRFEnergyEdgeFidelity.h:60
otbMRFEnergy.h
otb::MRFEnergyEdgeFidelity::Superclass
MRFEnergy< TInput1, TInput2 > Superclass
Definition: otbMRFEnergyEdgeFidelity.h:55
otb::MRFEnergyEdgeFidelity
This is the implementation of an edge preserving model for Markov denoising.
Definition: otbMRFEnergyEdgeFidelity.h:51
otb::MRFEnergyEdgeFidelity::LabelledImagePixelType
TInput2::PixelType LabelledImagePixelType
Definition: otbMRFEnergyEdgeFidelity.h:61
otb::MRFEnergyEdgeFidelity::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMRFEnergyEdgeFidelity.h:57
otb::MRFEnergyEdgeFidelity::NeighborhoodIterator
itk::ConstNeighborhoodIterator< TInput1 > NeighborhoodIterator
Definition: otbMRFEnergyEdgeFidelity.h:59
otb::MRFEnergyEdgeFidelity::GetSingleValue
double GetSingleValue(const InputImagePixelType &value1, const LabelledImagePixelType &value2) override
Definition: otbMRFEnergyEdgeFidelity.h:67
otb::MRFEnergy::LabelledImagePixelType
LabelledImageType::PixelType LabelledImagePixelType
Definition: otbMRFEnergy.h:54
otb::MRFEnergy::InputImagePixelType
InputImageType::PixelType InputImagePixelType
Definition: otbMRFEnergy.h:53
otb::MRFEnergyEdgeFidelity::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMRFEnergyEdgeFidelity.h:56
otb::MRFEnergyEdgeFidelity::MRFEnergyEdgeFidelity
MRFEnergyEdgeFidelity()
Definition: otbMRFEnergyEdgeFidelity.h:77
otb::MRFEnergy
This is the base class for energy function used in the MRF framework.
Definition: otbMRFEnergy.h:43
otb::MRFEnergyEdgeFidelity::Self
MRFEnergyEdgeFidelity Self
Definition: otbMRFEnergyEdgeFidelity.h:54