I have two ImgLib2
RandomAccessibleInterval objects with the same min/max bounds. One is empty, the other is populated with sample values.
I want to copy the populated image to the empty one. What is the best way to do that according to the ImgLib2 paradigm?
I know that one way is to use
LoopBuilder.setImages(srcImage, destImage).forEachPixel((src, dest) -> dest.set(src));
This is elegant, but uses a
BiConsumer lambda. I want to do the copy from Python (via pyimagej), so I’d prefer to call a method that doesn’t require a lambda.
Another way is to use ImageJ Ops:
ops.run("copy.rai", destImage, srcImage);
And ultimately this is how I want to do it, because it will select the most performant
copy.rai op based on the image types. But as a short-term performance fix, we are looking for a static method in ImgLib2 itself to do it directly, until the new SciJava Ops is released.
Relatedly, there is an open PR seeking to add this:
For those interested, the relevant pyimagej issue is: