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

Migrate paste

parent e736618d
......@@ -275,11 +275,11 @@ void paste_baseline(const mln::image2d<mln::rgb8>& in, mln::image2d<mln::rgb8>&
}
void paste(const mln::image2d<mln::uint8>& in, mln::image2d<mln::uint8>& out)
{
mln::experimental::paste(in, out);
mln::paste(in, out);
}
void paste(const mln::image2d<mln::rgb8>& in, mln::image2d<mln::rgb8>& out)
{
mln::experimental::paste(in, out);
mln::paste(in, out);
}
......
......@@ -27,67 +27,26 @@ namespace mln
/// \pre `output.domain()` includes `input.domain()`
/// \tparam InputImage is a model of the Forward Image.
/// \tparam OutputImage is a model of the Writable Point-Accessible Image
template <typename InputImage, typename OutputImage>
[[deprecated]] OutputImage& paste(const Image<InputImage>& input, Image<OutputImage>& output);
/// \ingroup Algorithms
/// \overload
template <typename InputImage, typename OutputImage>
[[deprecated]] OutputImage&& paste(const Image<InputImage>& input, Image<OutputImage>&& output);
namespace experimental
{
template <class InputImage, class OutputImage>
void copy(InputImage src, OutputImage dest);
}
template <class InputImage, class OutputImage>
void paste(InputImage src, OutputImage dest);
/******************************************/
/**** Implementation ****/
/******************************************/
namespace impl
{
template <typename I, typename J>
void paste(const I& ima, J& out)
{
mln_pixter(px, ima);
mln_forall (px)
out(px->point()) = px->val();
}
}
template <typename InputImage, typename OutputImage>
OutputImage& paste(const Image<InputImage>& input, Image<OutputImage>& output_)
{
impl::paste(exact(input), exact(output_));
return exact(output_);
}
template <typename InputImage, typename OutputImage>
OutputImage&& paste(const Image<InputImage>& input_, Image<OutputImage>&& output_)
template <class InputImage, class OutputImage>
void paste(InputImage src, OutputImage dest)
{
paste(input_, output_);
return move_exact(output_);
// FIXME: Add a precondition about the domain inclusion
// FIXME: check OutputImage is accessible
static_assert(mln::is_a<InputImage, experimental::Image>());
static_assert(mln::is_a<OutputImage, experimental::Image>());
static_assert(std::is_convertible_v<image_value_t<InputImage>, image_value_t<OutputImage>>);
auto&& pixels = src.new_pixels();
for (auto row : ranges::rows(pixels))
for (auto px : row)
dest(px.point()) = px.val();
}
namespace experimental
{
template <class InputImage, class OutputImage>
void paste(InputImage src, OutputImage dest)
{
// FIXME: Add a precondition about the domain inclusion
// FIXME: cech OutputImage is accessible
static_assert(mln::is_a<InputImage, Image>());
static_assert(mln::is_a<OutputImage, Image>());
static_assert(std::is_convertible_v<image_value_t<InputImage>, image_value_t<OutputImage>>);
auto&& pixels = src.new_pixels();
for (auto row : ranges::rows(pixels))
for (auto px : row)
dest(px.point()) = px.val();
}
} // namespace experimental
} // namespace mln
......@@ -36,7 +36,7 @@ TEST(Core, Experimental_Algorithm_Paste)
mln::image2d<uint8_t> out(15, 15);
mln::fill(ima, 69);
mln::iota(out, 1);
mln::experimental::paste(ima, out);
mln::paste(ima, out);
// 1 2 3 4..
// 16 x x 19
// 31 x x 34
......
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