what does this iteration do?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanctus
    New Member
    • Mar 2007
    • 84

    what does this iteration do?

    I'm working on an existing code and don't understand what the following iteration iterates over:

    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
                                      (...)
                            }
    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
    Code:
    MASK = mxGetPr(prhs[1]);
    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.
  • sanctus
    New Member
    • Mar 2007
    • 84

    #2
    Mo need to reply anymore, it took me an afternoon but I figured it out, thanks in case someone tried to understand

    Comment

    Working...