Zip (View)

Include <mln/core/image/view/zip.hpp>

  1. auto zip(Image... ima)
    1. Makes a view from ima where for each pixel value evals to out(p) = std::make_tuple(ima(p)...)

    Parameters:

    ima – Input ranges

    mln::image2d<int> ima1 = ...;
    mln::image2d<double> ima2 = ...;
    mln::image2d<mln::rgb8> ima3 = ...;
    auto g = mln::view::zip(ima1, ima2, ima3);
    

ima…

zip(ima…)

Category

Forward

X

X

Bidirectional

X

X

Raw

X

Properties

Writable

X

X

Accessible

X

X

Indexable

X

X

Examples

  • Traversing both input and output image at the same time:

mln::image2d<uint8_t> input = { {0, 1, 2}, {3, 4, 5} };
mln::image2d<uint8_t> output{input.domain()};
mln::fill(output, 0);
auto zipped_ima = mln::view::zip(input, output);
for (auto&& [v_in, v_out] : zipped_ima.values())
  v_out = v_in * v_in;

auto vals = zipped_ima.values();
for (auto r : mln::ranges::rows(vals))
{
  for (auto&& [_, v_out] : r)
    std::cout << v_out << " ";
  std::cout << std::endl;
}

Outputs:

0 1 4
9 16 25