Channel (View)

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

  1. auto channel(Image ima, unsigned k)
    1. Makes a view that project the k-th channel of a multi-channelled colored image, when k is only known at runtime.

    Parameters:

    ima – Input range

    mln::image2d<mln::rgb8> ima = ...;
    auto ima_red = mln::view::channel(ima, 0);
    

ima

channel(ima, k)

Category

Forward

X

X

Bidirectional

X

X

Raw

X

Properties

Writable

X

X

Accessible

X

X

Indexable

X

X

Examples

  • Set the red channel to max:

mln::image2d<mln::rgb8> ima = {
  { {0, 0, 255}, {0, 0, 255}, {0, 0, 255} },
  { {0, 0, 255}, {0, 0, 255}, {0, 0, 255} },
  { {0, 0, 255}, {0, 0, 255}, {0, 0, 255} }
  };
auto ima_red = mln::view::channel(ima, 0);
mln::fill(ima_red, 255);
mln::io::imprint(ima);

Outputs:

(255, 0, 255) (255, 0, 255) (255, 0, 255)
(255, 0, 255) (255, 0, 255) (255, 0, 255)
(255, 0, 255) (255, 0, 255) (255, 0, 255)