Generate
Include <mln/core/algorithm/generate.hpp>
-
template<class Generator>
void generate(OutputImage out, Generator g) Assigns each value in the image with a value generated by the given function object g. This is equivalent to the following code:
for (auto& vout : out.values()) vout = g();
- Parameters:
out – The output image.
g – The value generator.
- Template Parameters:
OutputImage – A model of
OutputImage
Generate – A model of :cpp:concept::std::Generator
Examples
Generate random values in the image:
std::default_random_engine e1(r()); std::uniform_int_distribution<int> g;
mln::image2d<int> ima(10, 10); mln::generate(ima, g);
Complexity
Linear in the number of pixels.