This file is indexed.

/usr/include/OTB-5.8/otbStandardDSCostFunction.txx is in libotb-dev 5.8.0+dfsg-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef otbStandardDSCostFunction_txx
#define otbStandardDSCostFunction_txx

#include "otbStandardDSCostFunction.h"

namespace otb
{
// Constructor
template <class TDSValidationFilter>
StandardDSCostFunction<TDSValidationFilter>
::StandardDSCostFunction() :
  m_CriterionFormula("((Belief + Plausibility)/2.)"),
  m_Weight(0.5)
{
 m_GTVectorData = VectorDataType::New();
 m_NSVectorData = VectorDataType::New();
 m_Parser =  ParserType::New();
}

template <class TDSValidationFilter>
unsigned int
StandardDSCostFunction<TDSValidationFilter>
::GetNumberOfParameters() const
 {
  return m_DescriptorList.size()*4;
 }

template <class TDSValidationFilter>
typename StandardDSCostFunction<TDSValidationFilter>
::MeasureType
 StandardDSCostFunction<TDSValidationFilter>
::GetValue(const ParametersType & parameters) const
 {
  if (parameters.size() != m_DescriptorList.size()*4)
    {
    itkExceptionMacro(<< "Wrong model!" )
    }

  //Initialize parser
  m_Parser->SetExpr(m_CriterionFormula);

  DescriptorsModelType descModel;
  for (unsigned int i = 0; i < m_DescriptorList.size(); ++i)
    {
    std::vector<double> tmp;
    for (unsigned int j = 0; j < 4; ++j)
      {
      tmp.push_back(parameters[4*i+j]);
      }
    PairType pair( m_DescriptorList[i], tmp);
    descModel.push_back(pair);
    }

  typename DSValidationFilterType::Pointer internalFunctionGT = DSValidationFilterType::New();
  internalFunctionGT->SetCriterionFormula("1");
  internalFunctionGT->SetInput(m_GTVectorData);
  internalFunctionGT->SetBeliefHypothesis(m_BeliefHypothesis);
  internalFunctionGT->SetPlausibilityHypothesis(m_PlausibilityHypothesis);
  try
    {
    internalFunctionGT->SetDescriptorModels(descModel);
    }
  catch (itk::ExceptionObject /*& err*/)
    {
    return 1;
    }
  internalFunctionGT->Update();

  typename DSValidationFilterType::Pointer internalFunctionNS = DSValidationFilterType::New();
  internalFunctionNS->SetCriterionFormula("1");
  internalFunctionNS->SetInput(m_NSVectorData);
  internalFunctionNS->SetBeliefHypothesis(m_BeliefHypothesis);
  internalFunctionNS->SetBeliefHypothesis(m_PlausibilityHypothesis);
  try
    {
    internalFunctionNS->SetDescriptorModels(descModel);
    }
  catch (itk::ExceptionObject &)
    {
    return 1;
    }
  internalFunctionNS->Update();

  double accGT = 0.0;
  double accNS = 0.0;
  double nGT = 0.0;
  double nNS = 0.0;

  TreeIteratorType itVectorGT(internalFunctionGT->GetOutput()->GetDataTree());
  itVectorGT.GoToBegin();
  while (!itVectorGT.IsAtEnd())
    {
    if (!itVectorGT.Get()->IsRoot() && !itVectorGT.Get()->IsDocument() && !itVectorGT.Get()->IsFolder())
      {
      double belief = itVectorGT.Get()->GetFieldAsDouble("Belief");
      double plausibility = itVectorGT.Get()->GetFieldAsDouble("Plausi");

      m_Parser->DefineVar("Belief", &belief);
      m_Parser->DefineVar("Plausibility", &plausibility);

      accGT += ((1 - m_Parser->Eval()) * (1 - m_Parser->Eval()));
      nGT += 1.0;

      m_Parser->ClearVar();
      }
    itVectorGT++;
    }

  TreeIteratorType itVectorNS(internalFunctionNS->GetOutput()->GetDataTree());
  itVectorNS.GoToBegin();
  while (!itVectorNS.IsAtEnd())
    {
    if (!itVectorNS.Get()->IsRoot() && !itVectorNS.Get()->IsDocument() && !itVectorNS.Get()->IsFolder())
      {
      double belief = itVectorNS.Get()->GetFieldAsDouble("Belief");
      double plausibility = itVectorNS.Get()->GetFieldAsDouble("Plausi");

      m_Parser->DefineVar("Belief", &belief);
      m_Parser->DefineVar("Plausibility", &plausibility);

      accNS += (m_Parser->Eval() * m_Parser->Eval());
      nNS += 1.0;

      m_Parser->ClearVar();
      }
    itVectorNS++;
    }
  return (m_Weight * accGT / nGT + (1 - m_Weight) * accNS / nNS);
}

template <class TDSValidationFilter>
void
StandardDSCostFunction<TDSValidationFilter>
::GetDerivative(const ParametersType & itkNotUsed(parameters), DerivativeType & itkNotUsed(derivative)) const
 {
  //Not necessary for Amoeba Optimizer
  itkExceptionMacro(<< "Not Supposed to be used when using Amoeba Optimizer!")
 }

// PrintSelf Method
template <class TDSValidationFilter>
void
StandardDSCostFunction<TDSValidationFilter>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
  Superclass::PrintSelf(os, indent);
}


}// end namespace otb

#endif