Filter (View)

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

  1. auto filter(Image ima, Predicate pred)
    1. Makes a view where each pixel is kept if and only if the predicate pred(ima(p)) is true.

    Parameters:
    • ima – Input range

    • pred – Predicate to apply on pixel values

    mln::image2d<int> ima = ...;
    auto g1 = mln::view::filter(ima, [](int v) { return v > 125; });
    

ima

filter(ima, pred)

Category

Forward

X

X

Bidirectional

X

X

Raw

X

Properties

Writable

X

Accessible

X

X

Indexable

X

X

Examples

  • Keep all add values:

mln::image2d<int> input = { {0, 1, 2}, {3, 4, 5} };
auto g = mln::view::transform(input, [](int v) { return v % 2 != 0; });
mln::io::imprint(g);

Outputs:

0 1
3 5