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

Annotate correctly to-be-removed old algorithms

parent 6062c79d
......@@ -25,19 +25,23 @@
typedef mln::morpho::component_tree<unsigned, mln::image2d<unsigned>> tree_t;
template <typename I, class AccuLike, class Extractor = mln::accu::default_extractor>
[[deprecated]] typename mln::accu::result_of<AccuLike, mln_value(I), Extractor>::type
__accumulate(const mln::Image<I>& input, const mln::AccumulatorLike<AccuLike>& accu_,
const Extractor& ex = Extractor())
// FIXME:
namespace to_migrate
{
const I& ima = exact(input);
auto a = mln::accu::make_accumulator(exact(accu_), mln_value(I)());
template <typename I, class AccuLike, class Extractor = mln::accu::default_extractor>
[[deprecated]] typename mln::accu::result_of<AccuLike, mln_value(I), Extractor>::type
__accumulate(const mln::Image<I>& input, const mln::AccumulatorLike<AccuLike>& accu_,
const Extractor& ex = Extractor())
{
const I& ima = exact(input);
auto a = mln::accu::make_accumulator(exact(accu_), mln_value(I)());
mln_foreach (const auto& v, ima.values())
a.take(v);
mln_foreach (const auto& v, ima.values())
a.take(v);
return ex(a);
}
return ex(a);
}
} // namespace to_migrate
namespace mln
{
......@@ -55,7 +59,8 @@ namespace mln
float amap_max;
{
auto tmp = make_image(tree, amap);
amap_max = __accumulate(tmp, accu::features::max<>());
// FIXME:
amap_max = ::to_migrate::__accumulate(tmp, accu::features::max<>());
for (float x = 0.1; x < amap_max; x += 0.1)
lambdas.push_back(x);
......
......@@ -6,19 +6,23 @@
#include <mln/io/imsave.hpp>
template <typename I, class AccuLike, class Extractor = mln::accu::default_extractor>
[[deprecated]] typename mln::accu::result_of<AccuLike, mln_value(I), Extractor>::type
__accumulate(const mln::Image<I>& input, const mln::AccumulatorLike<AccuLike>& accu_,
const Extractor& ex = Extractor())
// FIXME:
namespace to_migrate
{
const I& ima = exact(input);
auto a = mln::accu::make_accumulator(exact(accu_), mln_value(I)());
template <typename I, class AccuLike, class Extractor = mln::accu::default_extractor>
[[deprecated]] typename mln::accu::result_of<AccuLike, mln_value(I), Extractor>::type
__accumulate(const mln::Image<I>& input, const mln::AccumulatorLike<AccuLike>& accu_,
const Extractor& ex = Extractor())
{
const I& ima = exact(input);
auto a = mln::accu::make_accumulator(exact(accu_), mln_value(I)());
mln_foreach (const auto& v, ima.values())
a.take(v);
mln_foreach (const auto& v, ima.values())
a.take(v);
return ex(a);
}
return ex(a);
}
} // namespace to_migrate
int main(int argc, char** argv)
{
......@@ -39,9 +43,10 @@ int main(int argc, char** argv)
auto g_ = mln::imcast<rgb<float>>(g);
auto diff = imtransform(f_ - g_, [](rgb<float> x) -> double { return l2norm_sqr(x); });
auto dims = f.domain().shape();
double sum = __accumulate(diff, accu::features::sum<double>());
double MSE = sum / (3 * dims[0] * dims[1]);
auto dims = f.domain().shape();
// FIXME:
double sum = ::to_migrate::__accumulate(diff, accu::features::sum<double>());
double MSE = sum / (3 * dims[0] * dims[1]);
std::cout << "MSE: " << MSE << "\n";
if (MSE == 0)
......
......@@ -13,6 +13,39 @@
#include <type_traits>
// FIXME:
namespace to_migrate
{
namespace impl
{
// Clone by copy construction
template <typename Image>
mln_concrete(Image) clone(const Image& ima, std::true_type _use_copy_construction_)
{
(void)_use_copy_construction_;
mln_concrete(Image) x(ima);
return x;
}
// Clone by deep copy
template <typename Image>
mln_concrete(Image) clone(const Image& ima, std::false_type _use_copy_construction_)
{
(void)_use_copy_construction_;
mln_concrete(Image) x = imconcretize(ima);
mln::copy(ima, x);
return x;
}
} // namespace impl
template <typename I>
[[deprecated]] mln_concrete(I) __clone(const mln::Image<I>& ima) {
return impl::clone(exact(ima), mln::check_t<(std::is_convertible<I, mln_concrete(I)>::value and
not mln::image_traits<mln_concrete(I)>::shallow_copy::value)>());
}
} // namespace to_migrate
namespace mln
{
......@@ -82,39 +115,6 @@ namespace mln
// return internal::are_indexes_compatible(exact(f), exact(g));
}
// FIXME:
namespace detail
{
namespace impl
{
// Clone by copy construction
template <typename Image>
mln_concrete(Image) clone(const Image& ima, std::true_type _use_copy_construction_)
{
(void)_use_copy_construction_;
mln_concrete(Image) x(ima);
return x;
}
// Clone by deep copy
template <typename Image>
mln_concrete(Image) clone(const Image& ima, std::false_type _use_copy_construction_)
{
(void)_use_copy_construction_;
mln_concrete(Image) x = imconcretize(ima);
mln::copy(ima, x);
return x;
}
} // namespace impl
template <typename I>
[[deprecated]] mln_concrete(I) __clone(const Image<I>& ima) {
return impl::clone(exact(ima), check_t < std::is_convertible<I, mln_concrete(I)>::value and
not image_traits<mln_concrete(I)>::shallow_copy::value > ());
}
} // namespace detail
template <typename InputImage>
inline typename std::enable_if<image_traits<InputImage>::concrete::value, InputImage&&>::type eval(InputImage&& ima)
{
......@@ -127,6 +127,6 @@ namespace mln
eval(InputImage&& ima)
{
// FIXME:
return detail::__clone(std::forward<InputImage>(ima));
return ::to_migrate::__clone(std::forward<InputImage>(ima));
}
} // namespace mln
......@@ -7,31 +7,34 @@
#include <queue>
namespace impl
// FIXME:
namespace to_migrate
{
template <typename I, typename V>
void fill(I& ima, const V& v)
namespace impl
{
mln_viter(pin, ima);
mln_forall (pin)
*pin = v;
}
} // namespace impl
template <typename I, typename V>
void fill(I& ima, const V& v)
{
mln_viter(pin, ima);
mln_forall (pin)
*pin = v;
}
} // namespace impl
template <typename OutputImage, typename Value>
OutputImage& __fill(mln::Image<OutputImage>& output_, const Value& val)
{
OutputImage& output = mln::exact(output_);
impl::fill(output, val);
return output;
}
template <typename OutputImage, typename Value>
[[deprecated]] OutputImage& __fill(mln::Image<OutputImage>& output_, const Value& val) {
OutputImage& output = mln::exact(output_);
impl::fill(output, val);
return output;
}
template <typename OutputImage, typename Value>
OutputImage&& __fill(mln::Image<OutputImage>&& output_, const Value& val)
{
__fill(output_, val);
return mln::move_exact(output_);
}
template <typename OutputImage, typename Value>
[[deprecated]] OutputImage&& __fill(mln::Image<OutputImage>&& output_, const Value& val)
{
__fill(output_, val);
return mln::move_exact(output_);
}
} // namespace to_migrate
namespace mln
{
......@@ -87,7 +90,8 @@ namespace mln
static_assert(std::is_same<mln_value(J), bool>::value, "Output image value type must be bool");
__fill(out, true);
// FIXME:
::to_migrate::__fill(out, true);
extension::fill(out, false);
impl::saturate(ima, nbh, out, pinf);
}
......
......@@ -12,33 +12,37 @@
/// \file
// FIXME:
namespace impl
namespace to_migrate
{
template <typename I, typename J, class UnaryFunction>
void transform(const I& input, UnaryFunction f, J& output)
namespace impl
{
mln_viter(vin, vout, input, output);
mln_forall (vin, vout)
*vout = f(*vin);
template <typename I, typename J, class UnaryFunction>
void transform(const I& input, UnaryFunction f, J& output)
{
mln_viter(vin, vout, input, output);
mln_forall (vin, vout)
*vout = f(*vin);
}
} // namespace impl
template <typename InputImage, typename OutputImage, class UnaryFunction>
[[deprecated]] OutputImage& __transform(const mln::Image<InputImage>& input, UnaryFunction f,
mln::Image<OutputImage>& output) {
OutputImage& out = exact(output);
mln_entering("mln::transform");
impl::transform(exact(input), f, exact(output));
mln_exiting();
return out;
}
} // namespace impl
template <typename InputImage, typename OutputImage, class UnaryFunction>
OutputImage& __transform(const mln::Image<InputImage>& input, UnaryFunction f, mln::Image<OutputImage>& output)
{
OutputImage& out = exact(output);
mln_entering("mln::transform");
impl::transform(exact(input), f, exact(output));
mln_exiting();
return out;
}
template <typename InputImage, typename OutputImage, class UnaryFunction>
OutputImage&& __transform(const mln::Image<InputImage>& input, UnaryFunction f, mln::Image<OutputImage>&& output)
{
__transform(input, f, output);
return move_exact(output);
}
template <typename InputImage, typename OutputImage, class UnaryFunction>
[[deprecated]] OutputImage&& __transform(const mln::Image<InputImage>& input, UnaryFunction f,
mln::Image<OutputImage>&& output)
{
__transform(input, f, output);
return move_exact(output);
}
} // namespace to_migrate
namespace mln
......@@ -162,7 +166,7 @@ namespace mln
auto e = morpho::structural::erode(ima, nbh, cmp);
// FIXME:
__transform(d - e, norm, out);
::to_migrate::__transform(d - e, norm, out);
}
// Version non-fast dilate - erode
......
......@@ -10,32 +10,34 @@
#include <mln/morpho/tos/private/propagation.hpp>
// FIXME
namespace impl
// FIXME:
namespace to_migrate
{
template <typename I, typename V>
void fill(I& ima, const V& v)
namespace impl
{
mln_viter(pin, ima);
mln_forall (pin)
*pin = v;
}
} // namespace impl
template <typename I, typename V>
void fill(I& ima, const V& v)
{
mln_viter(pin, ima);
mln_forall (pin)
*pin = v;
}
} // namespace impl
template <typename OutputImage, typename Value>
OutputImage& __fill(mln::Image<OutputImage>& output_, const Value& val)
{
OutputImage& output = mln::exact(output_);
impl::fill(output, val);
return output;
}
template <typename OutputImage, typename Value>
[[deprecated]] OutputImage& __fill(mln::Image<OutputImage>& output_, const Value& val) {
OutputImage& output = mln::exact(output_);
impl::fill(output, val);
return output;
}
template <typename OutputImage, typename Value>
OutputImage&& __fill(mln::Image<OutputImage>&& output_, const Value& val)
{
__fill(output_, val);
return mln::move_exact(output_);
}
template <typename OutputImage, typename Value>
[[deprecated]] OutputImage&& __fill(mln::Image<OutputImage>&& output_, const Value& val)
{
__fill(output_, val);
return mln::move_exact(output_);
}
} // namespace to_migrate
namespace mln
{
......@@ -77,7 +79,7 @@ namespace mln
auto dom = is2F.domain();
mln_point(J) step = 2; // {2,2} or {2,2,2}
// FIXME
__fill(is2F | make_strided_box(dom.pmin, dom.pmax, step), true);
::to_migrate::__fill(is2F | make_strided_box(dom.pmin, dom.pmax, step), true);
for (unsigned p = 0; p < S.size(); ++p)
{
......
......@@ -10,32 +10,34 @@
#include <gtest/gtest.h>
// FIXME
namespace impl
// FIXME:
namespace to_migrate
{
template <typename I, typename V>
void fill(I& ima, const V& v)
namespace impl
{
mln_viter(pin, ima);
mln_forall (pin)
*pin = v;
}
} // namespace impl
template <typename I, typename V>
void fill(I& ima, const V& v)
{
mln_viter(pin, ima);
mln_forall (pin)
*pin = v;
}
} // namespace impl
template <typename OutputImage, typename Value>
OutputImage& __fill(mln::Image<OutputImage>& output_, const Value& val)
{
OutputImage& output = mln::exact(output_);
impl::fill(output, val);
return output;
}
template <typename OutputImage, typename Value>
[[deprecated]] OutputImage& __fill(mln::Image<OutputImage>& output_, const Value& val) {
OutputImage& output = mln::exact(output_);
impl::fill(output, val);
return output;
}
template <typename OutputImage, typename Value>
OutputImage&& __fill(mln::Image<OutputImage>&& output_, const Value& val)
{
__fill(output_, val);
return mln::move_exact(output_);
}
template <typename OutputImage, typename Value>
[[deprecated]] OutputImage&& __fill(mln::Image<OutputImage>&& output_, const Value& val)
{
__fill(output_, val);
return mln::move_exact(output_);
}
} // namespace to_migrate
TEST(GraphCut, graph_iteration)
{
......@@ -135,8 +137,8 @@ TEST(GraphCut, graphcut_1)
image2d<bool> ori(5, 5);
mln::fill(ori, false);
// FIXME
__fill(ori | sbox2d({0, 0}, {5, 5}, {2, 2}), true);
// FIXME:
::to_migrate::__fill(ori | sbox2d({0, 0}, {5, 5}, {2, 2}), true);
image2d<bool> out(5, 5);
......@@ -152,8 +154,8 @@ TEST(GraphCut, graphcut_2)
image2d<float> ori(5, 5);
mln::fill(ori, 0.0f);
// FIXME
__fill(ori | sbox2d({0, 0}, {5, 5}, {2, 2}), 0.7f);
// FIXME:
::to_migrate::__fill(ori | sbox2d({0, 0}, {5, 5}, {2, 2}), 0.7f);
image2d<bool> out(5, 5);
......
......@@ -8,13 +8,17 @@
#include <gtest/gtest.h>
template <typename I, typename V>
void __iota(I& ima, V v)
// FIXME:
namespace to_migrate
{
mln_viter(vout, ima);
mln_forall (vout)
*vout = v++;
}
template <typename I, typename V>
[[deprecated]] void __iota(I& ima, V v) {
mln_viter(vout, ima);
mln_forall (vout)
*vout = v++;
}
} // namespace to_migrate
using namespace mln;
......@@ -63,7 +67,8 @@ TEST(Morpho, property_image)
property_map<tree_t, int> vmap(tree);
auto ima = make_image(tree, vmap);
__iota(ima, 0);
// FIXME::
::to_migrate::__iota(ima, 0);
{
int i = 0;
......@@ -83,7 +88,8 @@ TEST(Morpho, property_image_nbh)
property_map<tree_t, int> vmap(tree);
auto ima = make_image(tree, vmap);
__iota(ima, 1);
// FIXME:
::to_migrate::__iota(ima, 1);
{
std::vector<unsigned> voisins[7] = {{}, {2, 5}, {1, 3, 4}, {2}, {2}, {1, 6}, {5}};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment