 
 #define MAX_LABELS 256
 
-int cudaJFAApolloniusThrust(cudaGraphicsResource_t &computeImage, int image_size, int numLabels,
+int cudaJFAApolloniusThrust(cudaGraphicsResource_t &computeImage, int imageSize, int numLabels,
                             thrust::device_vector<float4> &seedbuffer,
                             thrust::device_vector<float> &distance_vector,
                             thrust::device_vector<int> &compute_vector,

  data[index] = cur_nearest;
}

__global__ void  /*__launch_bounds__(16)*/ jfa_thrust_gather(int image_size, int num_labels,
                                                             int* thrustptr, int* seedidptr, int* seedidxptr)
{
  int x = blockIdx.x*blockDim.x + threadIdx.x;
  int y = blockIdx.y*blockDim.y + threadIdx.y;
  int index = y*image_size + x;
  float4 color;
  int labelID = 100;
  int labelIndex = thrustptr[index];
  //int ly = labelID/image_size;
  //int lx = labelID - ly*image_size;

  //bool foundcolor = false;
  for (int i=0;i<num_labels;i++)
  {
    //int sly = seedptr[i]/image_size;
    //int slx = seedptr[i] - sly*image_size;
    //if (slx == lx && sly == ly)
    //{
    if (labelIndex == seedidxptr[i])

  compute_temp_vector = compute_vector;
  apollonius_cuda<<<dimGrid, dimBlock>>>(thrust::raw_pointer_cast(compute_vector.data()),
                                         thrust::raw_pointer_cast(distance_vector.data()),
                                         1, imageSize, imageSize);

  for(int k = (imageSize / 2); k > 0; k /= 2)
  {

    apollonius_cuda<<<dimGrid,dimBlock>>>(thrust::raw_pointer_cast(compute_vector.data()),
                                          thrust::raw_pointer_cast(distance_vector.data()),
                                          k, imageSize, imageSize);
  }

#endif
  // colorize diagram

  jfa_thrust_gather<<<dimGrid,dimBlock>>>(imageSize, numLabels, raw_ptr, idptr, idxptr);
  cudaThreadSynchronize();

  cudaGraphicsUnmapResources(1, &computeImage);
