     cudaMemcpy( finished_device, finished, sizeof(int), cudaMemcpyHostToDevice);
     region_grow_kernel<<<dimGrid, dimBlock>>>(data_device, region_device, finished_device);
     cudaMemcpy( finished, finished_device, sizeof(int), cudaMemcpyDeviceToHost);
-    printf("Finished: %i\n", finished[0]);
-
   }
   cudaMemcpy( region, region_device, DATA_DIM*DATA_DIM*DATA_DIM*sizeof(unsigned char), cudaMemcpyDeviceToHost);
   return region;

  int dz[6] = {0,0,0,0,-1,1};

  int3 pixel = {.x=x, .y=y, .z=z};
  if(region[pixel.z * DATA_DIM*DATA_DIM + pixel.y*DATA_DIM + pixel.x]==2){
    region[pixel.z * DATA_DIM*DATA_DIM + pixel.y*DATA_DIM + pixel.x] = 1;
    for(int n = 0; n < 6; n++){
      int3 candidate = pixel;
      candidate.x += dx[n];
      candidate.y += dy[n];
      candidate.z += dz[n];

      if(!inside(candidate)){
        continue;
      }

      if(region[candidate.z * DATA_DIM*DATA_DIM + candidate.y*DATA_DIM + candidate.x]){
        continue;
      }

      if(similar(data, pixel, candidate)){
        region[candidate.z * DATA_DIM*DATA_DIM + candidate.y*DATA_DIM + candidate.x] = 2;
        finished[0]=0;
      }
    }
  }

#include <stdlib.h>
#include <cuda.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>

#include "bmp.h"

