Cast (View)

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

  1. template<typename T>
    auto cast<T>(Image ima)
    1. Makes a view from ima where for each pixel value evals to out(p) = static_cast<T>(ima(p))

    Parameters:

    ima – Input range

    Template Parameters:

    T – Type to cast to

    mln::image2d<double> ima = ...;
    auto g1 = mln::view::cast<int>(ima);
    

ima

cast<T>(ima)

Category

Forward

X

X

Bidirectional

X

X

Raw

X

Properties

Writable

X

Accessible

X

X

Indexable

X

X

Examples

  • Double image to int:

mln::image2d<double> input = { {0.1, 1.1, 2.1}, {3.5, 4.5, 5.5} };
auto g = mln::view::cast<int>(input);
mln::io::imprint(g);

Outputs:

0 1 2
3 4 5