Commit e294bf16 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

clang-format

parent a71f750e
Pipeline #12669 passed with stages
in 12 minutes and 41 seconds
......@@ -33,16 +33,16 @@ int main(int argc, char** argv)
using namespace mln;
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
int eps = std::atoi(argv[4]);
float threshold1 = std::atof(argv[5]);
float threshold2 = std::atof(argv[6]);
const char* out_path = argv[7];
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
int eps = std::atoi(argv[4]);
float threshold1 = std::atof(argv[5]);
float threshold2 = std::atof(argv[6]);
const char* out_path = argv[7];
typedef morpho::component_tree<unsigned, image2d<unsigned>> tree_t;
tree_t tree;
tree_t tree;
{
std::ifstream f(tree_path, std::ios::binary);
morpho::load(f, tree);
......@@ -94,7 +94,7 @@ int main(int argc, char** argv)
image2d<uint16> tmp;
resize(tmp, ima);
auto& attr = nmser.get_vmap();
auto pred = [&attr, threshold2](const tree_t::node_type& x) { return threshold2 < attr[x]; };
auto pred = [&attr, threshold2](const tree_t::node_type& x) { return threshold2 < attr[x]; };
morpho::filter_direct_and_reconstruct(tree, make_functional_property_map<tree_t::node_type>(pred), vmap, tmp);
io::imsave(tmp, "selection.tiff");
}
......
......@@ -79,7 +79,7 @@ mln::image2d<float> compute_MSER_attribute(const mln::image2d<V>& f, const mln::
{ // canonical propagate to parent
unsigned y = parent[x];
unsigned a = area[x];
V v = f[x];
V v = f[x];
while (parent[y] != y and dist(v, f[y]) < eps)
{
y = parent[y];
......@@ -100,8 +100,8 @@ mln::image2d<float> compute_MSER_attribute(const mln::image2d<V>& f, const mln::
if (K[parent[x]] == K[x]) // not a canonical element
continue;
V v = f[x];
unsigned y = parent[x];
V v = f[x];
unsigned y = parent[x];
unsigned smally = parent[x];
while (dist(v, f[y]) < eps and y != parent[y])
{
......
#include "MSERArgparser.hpp"
#include <boost/program_options.hpp>
MSERArgParser::MSERArgParser() : m_desc("MSER options")
MSERArgParser::MSERArgParser()
: m_desc("MSER options")
{
namespace po = boost::program_options;
......
......@@ -32,7 +32,7 @@ mln::image2d<float> MSERArgParser::run(const boost::program_options::variables_m
const mln::image2d<T>& K, const mln::image2d<unsigned>& parent,
const std::vector<unsigned>& S)
{
std::string smode = vm["mode"].as<std::string>();
std::string smode = vm["mode"].as<std::string>();
eMSER_attribute mode;
if (smode == "MSER_DIFF")
mode = MSER_DIFF;
......@@ -43,8 +43,8 @@ mln::image2d<float> MSERArgParser::run(const boost::program_options::variables_m
else
throw boost::program_options::invalid_option_value("MSER mode");
float a0 = vm["a0"].as<float>();
float a1 = vm["a1"].as<float>();
float a0 = vm["a0"].as<float>();
float a1 = vm["a1"].as<float>();
float delta = vm["delta"].as<float>();
mln::image2d<float> amser = compute_MSER_attribute(f, K, parent, S, delta, mode);
......
......@@ -44,28 +44,28 @@ namespace mln
mln_entering("mln::compute_MSER");
typedef morpho::component_tree<P, Amap> tree_t;
typedef typename tree_t::node_type node_t;
typedef typename tree_t::node_type node_t;
property_map<tree_t, unsigned> aplus(tree);
property_map<tree_t, unsigned> aminus(tree, 0);
if (fsum == MSER_ABSOLUTE)
{
mln_reverse_foreach(auto n, tree.nodes())
mln_reverse_foreach (auto n, tree.nodes())
{
auto x = n;
while (x.get_parent_id() != tree.npos() and dist(vmap[n], vmap[x]) < eps)
x = x.parent();
aminus[x] = std::max<unsigned>(aminus[x], amap[n]);
aplus[n] = amap[x];
aplus[n] = amap[x];
}
}
else
{
mln_reverse_foreach(auto n, tree.nodes())
mln_reverse_foreach (auto n, tree.nodes())
{
auto x = n;
auto x = n;
float d = 0;
while (x.id() != x.get_parent_id() and d < eps)
{
......@@ -73,7 +73,7 @@ namespace mln
x = x.parent();
}
aminus[x] = std::max<unsigned>(aminus[x], amap[n]);
aplus[n] = amap[x];
aplus[n] = amap[x];
}
}
aplus[tree.get_root_id()] = amap[tree.get_root()];
......@@ -106,7 +106,7 @@ namespace mln
const AreaPropertyMap& amap, float eps, eMSER_attribute amser, eMSER_accum_type fsum)
{
typedef typename ValuePropertyMap::value_type V;
auto dist = [](V x, V y) -> float { return l2norm(x - y); };
auto dist = [](V x, V y) -> float { return l2norm(x - y); };
return compute_MSER(tree, vmap, amap, eps, amser, fsum, dist);
}
......
......@@ -55,13 +55,13 @@ namespace mln
{
mln_entering("mln::compute_regional_energy");
typedef morpho::component_tree<P, image2d<P>> tree_t;
typedef typename tree_t::node_type node_type;
typedef typename tree_t::vertex_id_t vertex_id_t;
typedef morpho::component_tree<P, image2d<P>> tree_t;
typedef typename tree_t::node_type node_type;
typedef typename tree_t::vertex_id_t vertex_id_t;
typedef typename accu::result_of<AccuLike, mln_value(I)>::type R;
const I& vmap = exact(valuemap);
auto acc = accu::make_accumulator(exact(accu_), mln_value(I)());
auto acc = accu::make_accumulator(exact(accu_), mln_value(I)());
typedef decltype(acc) Accu;
......@@ -114,7 +114,7 @@ namespace mln
// Compute external region attribute
{
property_map<tree_t, bool> dejavu(tree, false);
property_map<tree_t, bool> dejavu(tree, false);
std::vector<std::pair<vertex_id_t, vertex_id_t>> branches;
mln_pixter(px, vmap);
......
......@@ -52,8 +52,8 @@ namespace mln
ima.at(p + point2d{1, 1}) - 2 * ima.at(p) - 2 * ima.at(p + point2d{0, 1})) /
2.0;
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{0, 1};
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{0, 1};
if (den != 0)
curv.at(p_) = std::abs(uxx * sqr(uy) - 2 * uxy * ux * uy + uyy * sqr(ux)) / (den * std::sqrt(den));
else
......@@ -79,8 +79,8 @@ namespace mln
ima.at(p + point2d{1, 1})) /
2.0;
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{1, 0};
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{1, 0};
if (den != 0)
curv.at(p_) = std::abs(uxx * sqr(uy) - 2 * uxy * ux * uy + uyy * sqr(ux)) / (den * std::sqrt(den));
else
......
......@@ -28,14 +28,14 @@ int main(int argc, char** argv)
using namespace mln;
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
float threshold1 = std::atof(argv[4]);
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
float threshold1 = std::atof(argv[4]);
const char* output_path = argv[5];
typedef morpho::component_tree<unsigned, image2d<unsigned>> tree_t;
tree_t tree;
tree_t tree;
{
std::ifstream f(tree_path, std::ios::binary);
morpho::load(f, tree);
......@@ -81,8 +81,8 @@ int main(int argc, char** argv)
// 5. reconstruction
{
auto& attr = extincted.get_vmap();
image2d<float> sal = imchvalue<float>(ima).init(0);
auto& attr = extincted.get_vmap();
image2d<float> sal = imchvalue<float>(ima).init(0);
attribute_on_contour(tree, attr, sal);
io::imsave(sal, output_path);
}
......
......@@ -28,15 +28,15 @@ int main(int argc, char** argv)
using namespace mln;
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
float threshold1 = std::atof(argv[4]);
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
float threshold1 = std::atof(argv[4]);
const char* output_tree = argv[5];
const char* output_path = argv[6];
typedef morpho::component_tree<unsigned, image2d<unsigned>> tree_t;
tree_t tree;
tree_t tree;
{
std::ifstream f(tree_path, std::ios::binary);
morpho::load(f, tree);
......
......@@ -19,7 +19,7 @@ namespace mln
image2d<float> grad;
resize(grad, f).init(1.0);
box2d dom = f.domain();
box2d dom = f.domain();
sbox2d d2f = {dom.pmin - point2d{2, 2}, dom.pmax, point2d{2, 2}};
float lmax = l1norm(value_traits<V>::sup() - value_traits<V>::inf());
......@@ -31,7 +31,7 @@ namespace mln
grad.at(p + point2d{1, 1}) = 1 - l1norm(f.at(p) - f.at(p + point2d{2, 2})) / lmax;
}
auto res = compute_attribute_on_contour(tree, grad, accu::features::mean<>());
auto res = compute_attribute_on_contour(tree, grad, accu::features::mean<>());
res[tree.get_root()] = 1.0;
mln_exiting();
return res;
......
......@@ -45,18 +45,18 @@ int main(int argc, char** argv)
using namespace mln;
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
int eps = std::atoi(argv[4]);
float alpha = std::atof(argv[5]);
float beta = std::atof(argv[6]);
float gamma = std::atof(argv[7]);
float threshold1 = std::atof(argv[8]);
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
int eps = std::atoi(argv[4]);
float alpha = std::atof(argv[5]);
float beta = std::atof(argv[6]);
float gamma = std::atof(argv[7]);
float threshold1 = std::atof(argv[8]);
const char* output_path = argv[9];
typedef morpho::component_tree<unsigned, image2d<unsigned>> tree_t;
tree_t tree;
tree_t tree;
{
std::ifstream f(tree_path, std::ios::binary);
morpho::load(f, tree);
......@@ -75,8 +75,8 @@ int main(int argc, char** argv)
<< ima.domain() << " vs " << tree._get_data()->m_pmap.domain() << std::endl;
}
image2d<V> F = ima;
image2d<V> f = unimmerse_k1(F);
image2d<V> F = ima;
image2d<V> f = unimmerse_k1(F);
image2d<float> C = compute_curvature(transform(f, [](V x) { return l1norm(x); }));
accu::accumulators::accu_if<accu::accumulators::count<>, K1::is_face_2_t, point2d> counter;
......@@ -87,7 +87,7 @@ int main(int argc, char** argv)
morpho::filter_direct_inplace(tree, pred);
typedef std::conditional<std::is_scalar<V>::value, double, vec<double, value_traits<V>::ndim>>::type SumType;
auto amap = compute_regional_energy(tree, F, accu::features::variance<SumType>(), eps);
auto amap = compute_regional_energy(tree, F, accu::features::variance<SumType>(), eps);
amap[tree.get_root()] = 0;
auto amap2 =
......@@ -96,13 +96,13 @@ int main(int argc, char** argv)
// Compute energy and filter
property_map<tree_t, float> energy(tree);
{
point2d shp = ima.domain().shape();
float domlength = 2 * shp[0] + 2 * shp[1] - 4;
point2d shp = ima.domain().shape();
float domlength = 2 * shp[0] + 2 * shp[1] - 4;
mln_foreach (auto x, tree.nodes())
{
float v1 = amap[x][2] > 0 ? (alpha * (amap[x][0] + amap[x][1]) / amap[x][2]) : 0;
float v2 = beta * accu::extractor::mean(amap2[x]);
float v3 = std::exp(-gamma * accu::extractor::count(amap2[x]) / domlength);
float v1 = amap[x][2] > 0 ? (alpha * (amap[x][0] + amap[x][1]) / amap[x][2]) : 0;
float v2 = beta * accu::extractor::mean(amap2[x]);
float v3 = std::exp(-gamma * accu::extractor::count(amap2[x]) / domlength);
energy[x] = v1 + v2 + v3;
}
}
......@@ -118,8 +118,8 @@ int main(int argc, char** argv)
auto extincted = morpho::extinction(ienergy, morpho::tree_neighb_t());
{
auto& attr = extincted.get_vmap();
image2d<float> sal = set_value_on_contour(tree, attr);
auto& attr = extincted.get_vmap();
image2d<float> sal = set_value_on_contour(tree, attr);
io::imsave(sal, output_path);
}
}
......@@ -45,19 +45,19 @@ int main(int argc, char** argv)
using namespace mln;
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
int eps = std::atoi(argv[4]);
float alpha = std::atof(argv[5]);
float beta = std::atof(argv[6]);
float gamma = std::atof(argv[7]);
float threshold1 = std::atof(argv[8]);
const char* out_tree = argv[9];
const char* tree_path = argv[1];
const char* img_path = argv[2];
unsigned grain = std::atoi(argv[3]);
int eps = std::atoi(argv[4]);
float alpha = std::atof(argv[5]);
float beta = std::atof(argv[6]);
float gamma = std::atof(argv[7]);
float threshold1 = std::atof(argv[8]);
const char* out_tree = argv[9];
const char* output_path = argv[10];
typedef morpho::component_tree<unsigned, image2d<unsigned>> tree_t;
tree_t tree;
tree_t tree;
{
std::ifstream f(tree_path, std::ios::binary);
morpho::load(f, tree);
......@@ -76,8 +76,8 @@ int main(int argc, char** argv)
<< ima.domain() << " vs " << tree._get_data()->m_pmap.domain() << std::endl;
}
image2d<V> F = ima;
image2d<V> f = unimmerse_k1(F);
image2d<V> F = ima;
image2d<V> f = unimmerse_k1(F);
image2d<float> C = compute_curvature(transform(f, [](V x) { return l1norm(x); }));
accu::accumulators::accu_if<accu::accumulators::count<>, K1::is_face_2_t, point2d> counter;
......@@ -91,7 +91,7 @@ int main(int argc, char** argv)
morpho::save(tree, f);
}
typedef std::conditional<std::is_scalar<V>::value, double, vec<double, value_traits<V>::ndim>>::type SumType;
auto amap = compute_regional_energy(tree, F, accu::features::variance<SumType>(), eps);
auto amap = compute_regional_energy(tree, F, accu::features::variance<SumType>(), eps);
amap[tree.get_root()] = 0;
auto amap2 =
......@@ -100,13 +100,13 @@ int main(int argc, char** argv)
// Compute energy and filter
property_map<tree_t, float> energy(tree);
{
point2d shp = ima.domain().shape();
float domlength = 2 * shp[0] + 2 * shp[1] - 4;
point2d shp = ima.domain().shape();
float domlength = 2 * shp[0] + 2 * shp[1] - 4;
mln_foreach (auto x, tree.nodes())
{
float v1 = amap[x][2] > 0 ? (alpha * (amap[x][0] + amap[x][1]) / amap[x][2]) : 0;
float v2 = beta * accu::extractor::mean(amap2[x]);
float v3 = std::exp(-gamma * accu::extractor::count(amap2[x]) / domlength);
float v1 = amap[x][2] > 0 ? (alpha * (amap[x][0] + amap[x][1]) / amap[x][2]) : 0;
float v2 = beta * accu::extractor::mean(amap2[x]);
float v3 = std::exp(-gamma * accu::extractor::count(amap2[x]) / domlength);
energy[x] = v1 + v2 + v3;
}
}
......
......@@ -74,7 +74,7 @@ namespace mln
template <typename V>
struct energy_t
{
typedef typename energy_helper<V>::sum_type sum_type;
typedef typename energy_helper<V>::sum_type sum_type;
typedef typename energy_helper<V>::sum_sqr_type sum_sqr_type;
enum
{
......@@ -85,17 +85,17 @@ namespace mln
static float beta;
static float gamma;
bool dejavu = false;
int depth = -1;
int m_e_length = 0;
float m_e_sumcurv = 0;
int m_v_n_int = 0;
sum_type m_v_sum_int = literal::zero;
bool dejavu = false;
int depth = -1;
int m_e_length = 0;
float m_e_sumcurv = 0;
int m_v_n_int = 0;
sum_type m_v_sum_int = literal::zero;
sum_sqr_type m_v_sum_int_sqr = literal::zero;
int m_v_n_ext = 0;
sum_type m_v_sum_ext = literal::zero;
int m_v_n_ext = 0;
sum_type m_v_sum_ext = literal::zero;
sum_sqr_type m_v_sum_ext_sqr = literal::zero;
unsigned m_area = 0;
unsigned m_area = 0;
energy_t() {}
......@@ -125,7 +125,7 @@ namespace mln
float a = var2 - var1;
float b = -2 * (m1 * var2 - m2 * var1);
float c = sqr(m1) * var2 - sqr(m2) * var1 - 2 * var1 * var2 * std::log(sqrt(var2 / var1));
delta = sqr(b) - 4 * a * c;
delta = sqr(b) - 4 * a * c;
if (delta == 0)
return std::make_pair(-b / (2 * a), 0.0f);
float r1 = (-b - sqrt(delta)) / (2 * a);
......@@ -135,7 +135,7 @@ namespace mln
float external_energy() const
{
float Vin = var(m_v_sum_int, m_v_sum_int_sqr, m_v_n_int);
float Vin = var(m_v_sum_int, m_v_sum_int_sqr, m_v_n_int);
float Vout = var(m_v_sum_ext, m_v_sum_ext_sqr, m_v_n_ext);
// float Vtotal = var(m_v_sum_int + m_v_sum_ext,
// m_v_sum_int_sqr + m_v_sum_ext_sqr,
......@@ -143,8 +143,8 @@ namespace mln
auto c1_ = (m_v_sum_int / (float)m_v_n_int);
auto c2_ = (m_v_sum_ext / (float)m_v_n_ext);
auto v_ = c2_ - c1_;
auto v = (v_) / (float)l2norm(v_);
auto v_ = c2_ - c1_;
auto v = (v_) / (float)l2norm(v_);
float c1 = sum(c1_ * v);
float c2 = sum(c2_ * v);
......@@ -176,8 +176,8 @@ namespace mln
{
float delta;
float a, b;
auto hf = [c1, Vin](float x) { return 0.5 * (1 + std::erf((x - c1) / std::sqrt(2 * M_PI * Vin))); };
auto hg = [c2, Vout](float x) { return 0.5 * (1 + std::erf((x - c2) / std::sqrt(2 * M_PI * Vout))); };
auto hf = [c1, Vin](float x) { return 0.5 * (1 + std::erf((x - c1) / std::sqrt(2 * M_PI * Vin))); };
auto hg = [c2, Vout](float x) { return 0.5 * (1 + std::erf((x - c2) / std::sqrt(2 * M_PI * Vout))); };
std::tie(a, b) = inter(c1, Vin, c2, Vout, delta);
if (delta == 0)
......@@ -283,20 +283,20 @@ namespace mln
const image2d<T>& K)
{
std::vector<unsigned> v;
int mindepth = value_traits<int>::max();
unsigned minp = 0;
int mindepth = value_traits<int>::max();
unsigned minp = 0;
mln_forall (x)
{
if (!K.domain().has(x->point()))
continue;
unsigned i = x->index();
i = (parent[i] != (unsigned)-1 and K[i] == K[parent[i]]) ? parent[i] : i;
i = (parent[i] != (unsigned)-1 and K[i] == K[parent[i]]) ? parent[i] : i;
v.push_back(i);
if (e[i].depth < mindepth)
{
mindepth = e[i].depth;
minp = i;
minp = i;
}
}
......@@ -307,14 +307,14 @@ namespace mln
for (unsigned& i : v)
if (e[i].depth > mindepth)
{
i = parent[i];
i = parent[i];
modif = true;
}
else if (e[i].depth == mindepth and i != minp)
{
i = parent[i];
mindepth--;
minp = i;
minp = i;
modif = true;
}
}
......@@ -386,8 +386,8 @@ namespace mln
ima.at(p + point2d{1, 1}) - 2 * ima.at(p) - 2 * ima.at(p + point2d{0, 1})) /
2.0;
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{0, 1};
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{0, 1};
if (den != 0)
curv.at(p_) = std::abs(uxx * sqr(uy) - 2 * uxy * ux * uy + uyy * sqr(ux)) / (den * std::sqrt(den));
else
......@@ -428,8 +428,8 @@ namespace mln
ima.at(p + point2d{1, 1})) /
2.0;
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{1, 0};
float den = (sqr(ux) + sqr(uy));
point2d p_ = p * 2 + point2d{1, 0};
if (den != 0)
curv.at(p_) = std::abs(uxx * sqr(uy) - 2 * uxy * ux * uy + uyy * sqr(ux)) / (den * std::sqrt(den));
else
......@@ -448,18 +448,18 @@ namespace mln
const std::vector<unsigned>& S, float alpha, float beta, float gamma, int eps = 5,
image2d<internal::energy_t<V>>* feedback = NULL)
{
typedef typename internal::energy_helper<V>::sum_type vec_sum_t;
typedef typename internal::energy_helper<V>::sum_type vec_sum_t;
typedef typename internal::energy_helper<V>::sum_sqr_type vec_sum_sqr_t;
extension::fill(ima, ima(ima.domain().pmin));
image2d<float> curv = curvature_on_edge(ima);
image2d<float> curv = curvature_on_edge(ima);
image2d<unsigned>& parent = const_cast<image2d<unsigned>&>(parent_);
mln_entering("mln::compute_energy");
internal::energy_t<V>::alpha = alpha;
internal::energy_t<V>::beta = beta;
internal::energy_t<V>::beta = beta;
internal::energy_t<V>::gamma = gamma;
image2d<internal::energy_t<V>> acc;
......@@ -522,7 +522,7 @@ namespace mln
}
typedef dyn_neighborhood<std::vector<point2d>, dynamic_neighborhood_tag> Nbh;
std::vector<point2d> dpoints;
std::vector<point2d> dpoints;
for (int i = -eps * 2; i <= eps * 2; i += 2)
for (int j = -eps * 2; j <= eps * 2; j += 2)
dpoints.emplace_back(i, j);
......@@ -541,7 +541,7 @@ namespace mln
if (K1::is_face_2(px->point()))
{
unsigned x = px->index();
x = (x != S[0] and K[x] == K[parent[x]]) ? parent[x] : x;
x = (x != S[0] and K[x]<