Copy
Include <mln/core/algorithm/copy.hpp>
-
void copy(InputImage src, OutputImage dst)
Copy the values from the source image src to destination image dst without considering the location. To consider the domain, see
mln::paste()
. This is equivalent to the following code:for (auto&& [vin,vout] : ranges::view::zip(src.values(), dst.values()) vout = vin;
The source and destination images should not alias. This function has a parallel implementation, see following section for an example.
- Parameters:
src – The source image
dst – The destination image
- Template Parameters:
InputImage – A model of
InputImage
OutputImage – A model of
OutputImage
Examples
Copy the red component into the green component:
mln::image2d<mln::rgb8> f = ...; mln::copy(mln::view::red(f), mln::view::green(f));
Copy a upper left part of an image into the lower right part:
mln::image2d<mln::rgb8> f(20,20); mln::box2d tl = {{0,0}, {10,10}}; mln::box2d br = {{10,10}, {20,20}}; mln::copy(mln::view::clip(f, tl), mln::view::clip(f, br)); // or mln::copy(f | tl, f | br);
Using parallel copy to copy the red component into the green component:
mln::image2d<mln::rgb8> f = ...; mln::parallel::copy(mln::view::red(f), mln::view::green(f));
Complexity
Linear in the number of pixels.