Fill

Include <mln/core/algorithm/fill.hpp>

template<class V>
void fill(OutputImage ima, const V &value)

Assign the value value to each pixel of the image. This is equivalent to the following code:

for (auto& vout : ima.values())
    vout = value;

This function has a parallel implementation, see following section for an example.

Parameters:
  • ima – The image to be filled.

  • value – The value to fill with.

Template Parameters:

Examples

  1. Set the pixels to a color:

    mln::image2d<mln::rgb8> f = ...;
    mln::fill(f, mln::rgb8{255,0,0});
    
  2. Set the red component of a RGB image:

    mln::image2d<mln::rgb8> f = ...;
    mln::fill(mln::view::red(f), 69);
    
  3. Using parallel fill to set the pixels to a color:

    mln::image2d<mln::rgb8> f = ...;
    mln::parallel::fill(f, mln::rgb8{255,0,0});
    

Complexity

Linear in the number of pixels.