any idea why this does not work?
DM::Image im2D = DM::RealImage("2D", 4, 2048);
DM::Image im3D= DM::RealImage("3D", 4, 2048, 9, 9);
PlugIn::ImageDataLocker im2D_LLl(im2D, PlugIn::ImageDataLocker::lock_data_CONTIGUOUS);
float *im2D_data = (float*)(im2D_LLl.get_image_data().get_data());
for (int i = 0; i <2048; i++) *Im2D_data++ = i;
Imaging::DataSlice planeSlice;
long xi=0, yi=0;
planeSlice = Imaging::DataSlice(Imaging::DataIndex(xi, yi, 0), Imaging::DataSlice::Slice1(2, 2048, 1));
DM::SliceImage(im3D, planeSlice) = im2D;
im3D is not changed, giving only zeros. In DM scripting side this would be:
slice1(im3D, 0,0,0,2,2048,1) = im2D
which works fine.
I'm somewhat confused by your example code.
It seems you create a 3D image of XYZ = 2048 x 9 x 9
but then slice it along dim=2 (z) for 2048 channels (it has only 9!)
The same is true for you script code.
slice1
creates a 1D image along the dimension 2.I think you've meant to use
slice2( img3D, 0,0,0, 0,9,1, 1,9,1 ) = img2d
Or, if you really meant to do spectrum-insertion (as you title suggests), you want some better named variables for sure.
Script example of creating a stack and filling it plane-wise:
Script example of creating a stack and filling it spectrum-wise:
As for the SDK code: When you create an image locker to change the data, make sure you use
im2d.DataChanged();
to finalize and update the image object.