       const Scalar * __restrict__ voxels,
 #endif
       int firstSlice, int lastSlice,
-      int from, int to)
+      int2 from, int2 to)
 {
 #ifndef VOLTEX3D
 #ifdef PITCHED

      const Scalar * __restrict__ voxels,
#endif
      int firstSlice, int lastSlice,
      int from, int to);

//----------------------------------------------------------------------------
// device code (CUDA)
//----------------------------------------------------------------------------

__device__ int2 coord(int from)
{
    return make_int2(threadIdx.x + blockDim.x*blockIdx.x,
            threadIdx.y + blockDim.y*blockIdx.y + from);
}

__global__ void clearImage(uchar4 * __restrict__ img, int width, int height,
      int from, int to)
{
    const int2 p = coord(from);
    if (p.y >= to)
        return;
    if (p.x >= width)
        return;


        // Traverse intermediate image pixels which correspond to the current slice.
        // 1 is subtracted from each loop counter to remain inside of the volume boundaries:
        for (int ix=threadIdx.x+from.x; ix<endX; ix+=blockDim.x)
        {
            if(ix<iPosX)
                continue;
