Mask (View)

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

  1. auto mask(Image ima, BoolImage m)
    1. Makes a view where each pixel is kept if and only if the masked boolean m(p) is true.

    Parameters:
    • ima – Input range

    • mask – Input range

    mln::image2d<int> ima = ...;
    mln::image2d<bool> m = ...;
    auto g = mln::view::mask(ima, m);
    

ima

mask(ima, mask)

Category

Forward

X

X

Bidirectional

X

X

Raw

X

Properties

Writable

X

X

Accessible

X

X

Indexable

X

X

Examples

  • Set all odd values to 42:

mln::image2d<int> ima = { {0, 1, 2}, {3, 4, 5} };
mln::image2d<bool> m = ima % 2 == 1;
auto g = mln::view::mask(ima, m);
mln::fill(g, 42);
mln::io::imprint(ima);

Outputs:

0  42 2
42 4  42