I'm working on an existing code and don't understand what the following iteration iterates over:
I mean what is index exactly? MASK is an array of dimensions
dim[0] x dim[1] x dim[2] but index doesnt seem to me to iterate ovaer all elements of MASK (this can for example seen by the fact the first iteration gives index=1+rows+pa gesize=1+rows*( 1+dim[1]))
EDIT: to be precise MASK is imported from Matlab in the following way:
in the mexfunction there is
hence, Mask is a pointer to the second input element from the calling matlab function. And this calling Matlab function has as second argument an array of ones and zeros of the dimensions dim[0] x dim[1] x dim[2].
I hope it is clear.
Code:
rows = dim[0];
pagesize = dim[0]*dim[1];
for(ix=1;ix<dim[0]-1;ix++)
for(iy=1;iy<dim[1]-1;iy++)
for(iz=1;iz<dim[2]-1;iz++)
{
index = ix + iy*rows + iz*pagesize;
if(MASK[index]==0)
Gradient[index]=0;
else
(...)
}
dim[0] x dim[1] x dim[2] but index doesnt seem to me to iterate ovaer all elements of MASK (this can for example seen by the fact the first iteration gives index=1+rows+pa gesize=1+rows*( 1+dim[1]))
EDIT: to be precise MASK is imported from Matlab in the following way:
in the mexfunction there is
Code:
MASK = mxGetPr(prhs[1]);
I hope it is clear.
Comment