libmir / mir-cv

[WIP] Computer Vision
1 stars 2 forks source link

padStack #1

Closed 9il closed 7 years ago

9il commented 7 years ago

This issue is successor for https://github.com/libmir/mir/issues/311.

9il commented 7 years ago

padStack should return a mir.ndslice.stack.Stack. Then mir.ndslice.topology: indexed, ndiota can be used to construct a lazy view, or slice can be used to allocate new image.

9il commented 7 years ago

Draft for 2D:

auto pad(S)(S slice, size_t l0, size_t l1)
{
    auto e = slice[0 .. $, 0 .. $]; //if contiguous then canonical

    auto b = e[0 .. l0].reversed!0;
    auto h = e.reversed!0[0 .. l0];

    auto d = e[0 .. $, 0 .. l1].retro.reversed!0;
    auto f = e.retro.reversed!0[0 .. $, 0 .. l1];

    auto a = d[0 .. l0].reversed!0;
    auto c = f[0 .. l0].reversed!0;

    auto g = d.reversed!0[0 .. l0];
    auto k = f.reversed!0[0 .. l0];

    return
        stack!0(
            stack!1(a, b, c),
            stack!1(d, e, f),
            stack!1(g, h, k),
        );
}
9il commented 7 years ago

Hmm, probably we can add a multidimensional version to mir-algorithm

ljubobratovicrelja commented 7 years ago

Nice! :)

Hmm, probably we can add a multidimensional version to mir-algorithm

I agree!

9il commented 7 years ago

constant padding was added https://github.com/libmir/mir-algorithm/pull/31

9il commented 7 years ago

edge, symmetric and wrap paddings https://github.com/libmir/mir-algorithm/pull/32