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

Fix view directory layout

parent b793a39f
......@@ -3,7 +3,7 @@
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/grays.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <mln/core/trace.hpp>
......@@ -90,7 +90,7 @@ namespace mln
}
}
using namespace mln::experimental::ops;
using namespace mln::view::ops;
mln_postcondition(all_of(curv >= 0));
......
......@@ -2,7 +2,7 @@
#include <mln/core/algorithm/accumulate.hpp>
#include <mln/core/algorithm/copy.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <mln/core/utils/ptroffset.hpp>
using namespace mln;
......@@ -81,7 +81,7 @@ unsigned threshold3(const image2d<uint8>& f, uint8 v)
unsigned threshold4(const image2d<uint8>& f, uint8 v)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
return mln::accumulate(f < v, accu::accumulators::sum<unsigned>());
}
......
......@@ -75,11 +75,11 @@ See :doc:`core/images` for a description of the image concepts and image basics.
+--------------+-----------------------------------------------------------+
| Arithmetical | `a + b`, `a - b`, `a * b`, `a / b`, `a % b` |
+--------------+-----------------------------------------------------------+
| Logical | ``land(a,b)``, ``lor(a,b)``, ``lnot(a)`` |
| Logical | `a && b`, `a || b`, `! a` |
+--------------+-----------------------------------------------------------+
| Comparison | `a < b`, `a <= b`, `a == b`, `a != b`, `a >= b`, `a > b` |
+--------------+-----------------------------------------------------------+
| Conditional | ``view::ifelse(a,b,c)`` |
| Conditional | ``view::ifelse(a, b, c)`` |
+--------------+-----------------------------------------------------------+
......
#include <mln/core/algorithm/transform.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <mln/core/neighb2d.hpp>
#include <mln/core/neighborhood/dyn_wneighborhood.hpp>
#include <mln/core/se/disc.hpp>
......@@ -115,7 +115,7 @@ mln::rgb8 heat_lut(float x)
int main(int argc, char** argv)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
if (argc < 4)
{
......@@ -141,7 +141,7 @@ int main(int argc, char** argv)
auto ws = mln::morpho::experimental::watershed<mln::int16>(dinv, mln::c8, nlabel);
// (4) Labelize input
[[maybe_unused]] auto output = mln::experimental::where(ws == 0, 1, mln::experimental::where(input, ws, 0));
auto output = mln::view::ifelse(ws == 0, 1, mln::view::ifelse(input, ws, 0));
// END
auto d_stretched = mln::data::stretch<float>(d);
......
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <mln/core/neighb2d.hpp>
#include <mln/core/se/utility.hpp>
#include <mln/io/imread.hpp>
......@@ -10,7 +10,7 @@
int main(int argc, char** argv)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
if (argc < 7)
{
......@@ -47,12 +47,12 @@ int main(int argc, char** argv)
mln::io::experimental::imsave(not markers2, argv[3]);
}
auto markers = markers1 || markers2;
auto markers = markers1 || markers2;
mln::io::experimental::imsave(not markers, argv[4]);
// FIXME: add experimental version
auto markers_ = mln::lor(markers1, markers2);
auto markers_ = mln::lor(markers1, markers2);
auto all_touching = mln::morpho::opening_by_reconstruction(input, markers_, mln::c4);
mln::io::imsave(mln::lnot(all_touching), argv[5]);
......
......@@ -26,14 +26,6 @@ namespace mln
template <class V, class I>
casted_image<I, V> imcast(Image<I>&& ima);
namespace experimental
{
template <class I, class V>
using casted_image = transform_view<I, internal::cast_to<V>>;
template <class V, class IntputImage>
casted_image<IntputImage, V> imcast(IntputImage ima);
} // namespace experimental
/******************************************/
/**** Implementation ****/
......@@ -70,12 +62,4 @@ namespace mln
return casted_image<I, V>(move_exact(ima), internal::cast_to<V>{});
}
namespace experimental
{
template <class V, class IntputImage>
casted_image<IntputImage, V> imcast(IntputImage ima)
{
return view::transform(std::move(ima), internal::cast_to<V>{});
}
} // namespace experimental
} // namespace mln
......@@ -2,7 +2,7 @@
#include <boost/optional.hpp>
#include <mln/core/image/image.hpp>
// #include <mln/core/image/private/where.hpp>
// #include <mln/core/domain/where.hpp>
// #include <mln/core/image/view/clip.hpp>
#include <mln/core/image_base.hpp>
#include <mln/core/iterator/transform_iterator.hpp>
......
#pragma once
#include <mln/core/image/image.hpp>
#include <mln/core/image/view/transform.hpp>
#include <utility>
namespace mln::view
{
namespace detail
{
template <typename V>
struct cast_to
{
template <typename T>
V operator()(const T& v) const
{
return static_cast<V>(v);
}
};
} // namespace detail
template <class V, class InputImage>
auto cast(InputImage ima)
{
static_assert(is_a<InputImage, experimental::Image>());
return view::transform(std::move(ima), detail::cast_to<V>{});
}
} // namespace mln::view
#pragma once
#include <mln/core/domain/where.hpp>
#include <mln/core/image/image.hpp>
#include <mln/core/image/private/where.hpp>
#include <mln/core/image/view/adaptor.hpp>
#include <range/v3/view_facade.hpp>
......@@ -175,7 +175,6 @@ namespace mln
pixel_range_t new_pixels() { return {this->base().new_pixels(), m_mask.new_values()}; }
/// Accessible-image related methods (overwritten from adaptor)
/// \{
template <typename Ret = reference>
......
#pragma once
#include <functional>
#include <mln/core/image/view/transform.hpp>
#include <mln/core/image/view/zip.hpp>
#include <mln/core/rangev3/foreach.hpp>
namespace mln::experimental
#include <functional>
namespace mln::view
{
// Prevent ADL on those operators so that A+B uses old API
// and using mln::experimental::ops A+B uses new API
......@@ -14,7 +16,7 @@ namespace mln::experimental
{
#define MLN_PRIVATE_DEFINE_UNARY_OPERATOR(op, f) \
template <class I, class = std::enable_if_t<mln::is_a<I, Image>::value>> \
template <class I, class = std::enable_if_t<mln::is_a<I, mln::experimental::Image>::value>> \
auto op(const I& ima) \
{ \
return view::transform(static_cast<const I&>(ima), f); \
......@@ -25,20 +27,20 @@ namespace mln::experimental
namespace impl \
{ \
template <class I1, class I2> \
auto op(const Image<I1>& ima1, const Image<I2>& ima2) \
auto op(const mln::experimental::Image<I1>& ima1, const mln::experimental::Image<I2>& ima2) \
{ \
return view::transform(static_cast<const I1&>(ima1), static_cast<const I2&>(ima2), f); \
} \
\
template <class I, class Scalar, class = std::enable_if_t<!is_a<Scalar, Image>::value>> \
auto op(const Image<I>& ima1, Scalar s) \
template <class I, class Scalar, class = std::enable_if_t<!is_a<Scalar, mln::experimental::Image>::value>> \
auto op(const mln::experimental::Image<I>& ima1, Scalar s) \
{ \
auto g = [f_ = f, s](auto&& arg) { return f_(arg, s); }; \
return view::transform(static_cast<const I&>(ima1), g); \
} \
\
template <class Scalar, class I, class = std::enable_if_t<!is_a<Scalar, Image>::value>> \
auto op(Scalar s, const Image<I>& ima2) \
template <class Scalar, class I, class = std::enable_if_t<!is_a<Scalar, mln::experimental::Image>::value>> \
auto op(Scalar s, const mln::experimental::Image<I>& ima2) \
{ \
auto g = [f_ = f, s](auto&& arg) { return f_(s, arg); }; \
return view::transform(static_cast<const I&>(ima2), g); \
......@@ -46,10 +48,12 @@ namespace mln::experimental
} \
\
/* This overload is there to be a best match wrt old API impl */ \
template <class A, class B, class = std::enable_if_t<(is_a<A, Image>::value || is_a<B, Image>::value)>> \
template <class A, class B, \
class = std::enable_if_t<(is_a<A, mln::experimental::Image>::value || \
is_a<B, mln::experimental::Image>::value)>> \
auto op(const A& lhs, const B& rhs) \
{ \
return mln::experimental::ops::impl::op(lhs, rhs); \
return mln::view::ops::impl::op(lhs, rhs); \
}
......@@ -90,11 +94,13 @@ namespace mln::experimental
namespace details
{
template <class ICond, class ITrue, class IFalse, class = void>
struct where_fn;
struct ifelse_fn;
template <class ICond, class ITrue, class IFalse>
struct where_fn<ICond, ITrue, IFalse, std::enable_if_t<is_a<ITrue, Image>::value && is_a<IFalse, Image>::value>>
struct ifelse_fn<
ICond, ITrue, IFalse,
std::enable_if_t<is_a<ITrue, mln::experimental::Image>::value && is_a<IFalse, mln::experimental::Image>::value>>
{
auto operator()(const ICond& cond, ITrue iftrue, IFalse iffalse) const
{
......@@ -108,7 +114,9 @@ namespace mln::experimental
};
template <class ICond, class ITrue, class IFalse>
struct where_fn<ICond, ITrue, IFalse, std::enable_if_t<!is_a<ITrue, Image>::value && is_a<IFalse, Image>::value>>
struct ifelse_fn<ICond, ITrue, IFalse,
std::enable_if_t<!is_a<ITrue, mln::experimental::Image>::value &&
is_a<IFalse, mln::experimental::Image>::value>>
{
auto operator()(const ICond& cond, ITrue vtrue, IFalse iffalse) const
{
......@@ -121,7 +129,9 @@ namespace mln::experimental
};
template <class ICond, class ITrue, class IFalse>
struct where_fn<ICond, ITrue, IFalse, std::enable_if_t<is_a<ITrue, Image>::value && !is_a<IFalse, Image>::value>>
struct ifelse_fn<ICond, ITrue, IFalse,
std::enable_if_t<is_a<ITrue, mln::experimental::Image>::value &&
!is_a<IFalse, mln::experimental::Image>::value>>
{
auto operator()(const ICond& cond, ITrue iftrue, IFalse vfalse) const
{
......@@ -135,7 +145,9 @@ namespace mln::experimental
template <class ICond, class ITrue, class IFalse>
struct where_fn<ICond, ITrue, IFalse, std::enable_if_t<!is_a<ITrue, Image>::value && !is_a<IFalse, Image>::value>>
struct ifelse_fn<ICond, ITrue, IFalse,
std::enable_if_t<!is_a<ITrue, mln::experimental::Image>::value &&
!is_a<IFalse, mln::experimental::Image>::value>>
{
auto operator()(const ICond& cond, ITrue vtrue, IFalse vfalse) const
{
......@@ -146,13 +158,13 @@ namespace mln::experimental
} // namespace details
template <class ICond, class ITrue, class IFalse>
auto where(const Image<ICond>& cond, ITrue iftrue, IFalse iffalse)
auto ifelse(const mln::experimental::Image<ICond>& cond, ITrue iftrue, IFalse iffalse)
{
return details::where_fn<ICond, ITrue, IFalse>()(static_cast<const ICond&>(cond), std::move(iftrue),
std::move(iffalse));
return details::ifelse_fn<ICond, ITrue, IFalse>()(static_cast<const ICond&>(cond), std::move(iftrue),
std::move(iffalse));
}
#undef MLN_PRIVATE_DEFINE_UNARY_OPERATOR
#undef MLN_PRIVATE_DEFINE_BINARY_OPERATOR
} // namespace mln::experimental
} // namespace mln::view
......@@ -3,6 +3,7 @@
#include <mln/core/image/image.hpp>
#include <mln/core/image/view/adaptor.hpp>
#include <mln/core/rangev3/view/zip.hpp>
#include <tuple>
#include <type_traits>
......@@ -10,7 +11,6 @@
namespace mln
{
template <class... Images>
class zip_view : public experimental::Image<zip_view<Images...>>
{
......
......@@ -2,14 +2,14 @@
#include <mln/core/algorithm/any_of.hpp>
#include <mln/core/algorithm/none_of.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <gtest/gtest.h>
TEST(Core, Algorithm_Any)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
const mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
......@@ -23,7 +23,7 @@ TEST(Core, Algorithm_Any)
TEST(Core, Algorithm_All)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
const mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
......@@ -36,7 +36,7 @@ TEST(Core, Algorithm_All)
TEST(Core, Algorithm_None)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
const mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
......
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/algorithm/clone.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <gtest/gtest.h>
TEST(Core, Algorithm_Clone)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
const mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
auto out = mln::clone(ima);
......
......@@ -2,7 +2,7 @@
#include <mln/core/algorithm/fill.hpp>
#include <mln/core/grays.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <boost/range/algorithm/count.hpp>
......@@ -23,7 +23,7 @@ TEST(Core, Algorithm_Fill)
TEST(Core, Algorithm_Exp_Fill)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
mln::image2d<std::uint8_t> ima(10, 10);
mln::fill(ima, 69);
......
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/algorithm/for_each.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <utility>
......@@ -9,7 +9,7 @@
TEST(Core, Algorithm_For_Each)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
......@@ -22,7 +22,7 @@ TEST(Core, Algorithm_For_Each)
TEST(Core, Algorithm_For_Each_Side_Effects)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
......
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/algorithm/generate.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <gtest/gtest.h>
TEST(Core, Algorithm_Generate)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
// Another impl of mln::iota
int i = 1;
......
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/algorithm/iota.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <gtest/gtest.h>
TEST(Core, Algorithm_Iota)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
mln::image2d<uint8_t> out(3, 4);
mln::iota(out, 1);
......
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/algorithm/transform.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <utility>
......@@ -9,7 +9,7 @@
TEST(Core, Algorithm_Transform)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
mln::image2d<uint8_t> ima = {{1, 2, 3}, {4, 5, 6}};
......@@ -22,7 +22,7 @@ TEST(Core, Algorithm_Transform)
TEST(Core, Algorithm_Transform_LValue)
{
using namespace mln::experimental::ops;
using namespace mln::view::ops;
using V = std::pair<uint8_t, uint8_t>;
......
......@@ -4,7 +4,7 @@
#include <mln/core/extension/fill.hpp>
#include <mln/core/grays.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/operators.hpp>
#include <mln/io/imprint.hpp>
#include <gtest/gtest.h>
......@@ -12,7 +12,7 @@
TEST(Core, Extension_Fill)
{
using namespace mln;
using namespace mln::experimental::ops;
using namespace mln::view::ops;
image2d<uint8> ima(10, 10);
iota(ima, 0);
......
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