Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   copy from 2D array to 3D array (http://www.go4expert.com/forums/copy-2d-array-3d-array-t19747/)

hsash 12Oct2009 15:19

copy from 2D array to 3D array
 
hi all!

im having trouble copying from 2d array to 3d array. im not sure this is correct. can anyone help me? i suspect the error is in the last line.

Code:

void TwoDimToThree()
{
int i,j,k;
int row=512,col=512,slice;
//int slice_no = sav_slice_no[300];
for(slice=0;slice<slice_no;slice++)
{
for(j=0;j<row;j++)
{
for(k=0;k<col;k++)
{
Dim_image3D[slice][j][k]=image3D[slice][pixel];
}
}
}
}

thank you!

shabbir 12Oct2009 17:33

Re: copy from 2D array to 3D array
 
your image2D you are copying should be function of loop variables.

xpi0t0s 13Oct2009 13:16

Re: copy from 2D array to 3D array
 
Impossible to answer, since we don't know what you're trying to achieve. Are you copying from the 2D array to a single "slice" of the 3D array, or are you copying it to multiple slices? Are you mapping 2D pixels to exactly the same pixel in the slice, i.e. does 2D[p][q] get stored in 3D[slice][p][q]?

Is your 2D array really called "image3D"? Using misleading variable names is a great way to confuse yourself.


All times are GMT +5.5. The time now is 21:45.