/usr/include/mia-2.4/mia/template/divcurl.cxx is in libmia-2.4-dev 2.4.3-5.
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 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2016 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <limits>
#include <algorithm>
NS_MIA_BEGIN
template <typename T>
TDivCurlFullCost<T>::TDivCurlFullCost(double weight_div, double weight_curl, double weight):
TFullCost<T>(weight),
m_weight_div(weight_div),
m_weight_curl(weight_curl),
m_size_scale(1.0)
{
this->add(::mia::property_gradient);
}
template <typename T>
double TDivCurlFullCost<T>::do_evaluate(const T& t, CDoubleVector& gradient) const
{
assert(t.get_size() == this->get_current_size());
double result = t.get_divcurl_cost(m_size_scale * m_weight_div, m_size_scale *m_weight_curl, gradient);
cvdebug() << "TDivCurlFullCost<T>::value = " << result << "\n";
std::transform(gradient.begin(), gradient.end(), gradient.begin(), [](double x){return -1.0 * x;});
return result;
}
template <typename T>
double TDivCurlFullCost<T>::do_value(const T& t) const
{
double result = t.get_divcurl_cost(m_size_scale * m_weight_div, m_size_scale * m_weight_curl);
cvdebug() << "TDivCurlFullCost<T>::value = " << result << "\n";
return result;
}
template <typename T>
double TDivCurlFullCost<T>::do_value() const
{
cvwarn() << "Requesting DivCurl cost without a transformation doesn't make sense\n";
return 0.0;
}
template <typename T>
void TDivCurlFullCost<T>::do_set_size()
{
m_size_scale = 1.0 / (this->get_current_size().product());
}
template <typename T>
bool TDivCurlFullCost<T>::do_get_full_size(Size& /*size*/) const
{
return true;
}
template <typename T>
TDivcurlFullCostPlugin<T>::TDivcurlFullCostPlugin():
TFullCostPlugin<T>("divcurl"),
m_div(1.0),
m_curl(1.0)
{
this->add_parameter("div", new CFloatParameter(m_div, 0.0f, std::numeric_limits<float>::max(),
false, "penalty weight on divergence"));
this->add_parameter("curl", new CFloatParameter(m_curl, 0.0f, std::numeric_limits<float>::max(),
false, "penalty weight on curl"));
}
template <typename T>
TFullCost<T> *TDivcurlFullCostPlugin<T>::do_create(float weight) const
{
cvdebug() << "create C2DDivCurlFullCost with weight= " << weight
<< " div=" << m_div << " curl=" << m_curl << "\n";
return new TDivCurlFullCost<T>(this->m_div, this->m_curl, weight);
}
template <typename T>
const std::string TDivcurlFullCostPlugin<T>::do_get_descr() const
{
return "divcurl penalty cost function";
}
NS_MIA_END
|