                                 labelPosition.z(), labelPosition.w());
     int index = static_cast<int>(labelPosition.y()) +
                 static_cast<int>(labelPosition.z()) * imageSize;
-    std::cout << index << " -> " << labelPosition.x() << std::endl;
     pixelIndexToLabelId[index] = labelPosition.x();
   }
 

  // left border from bottom to top
  destination[imageSize * 3 + index] =
      source[maxIndex - imageSize + 1 - index * imageSize];

  /*const int yp1 = index / imageSize;
  const int xp1 = index - yp1*imageSize;
  const int yp2 = ((imageSize-1) + index*imageSize) / imageSize;
  const int xp2 = ((imageSize-1) + index*imageSize) - yp2*imageSize;
  const int yp3 = (maxIndex - index) / imageSize;
  const int xp3 = (maxIndex - index) - yp3*imageSize;
  const int yp4 = (maxIndex - imageSize + 1 - index*imageSize) / imageSize;
  const int xp4 = (maxIndex - imageSize + 1 - index*imageSize) -
  yp4*imageSize;
  printf("%d: %d %d, %d %d, %d %d, %d %d\n", index, xp1, yp1, xp2, yp2, xp3,
  yp3, xp4, yp4);*/

  //__syncthreads();
  /*if ((destination[index] == 0) || (destination[imageSize + index ] == 0) ||
  (destination[imageSize*2 + index] == 0) || (destination[imageSize*3 + index]
  == 0))
  {
    printf("buffer is 0: %d: %d %d %d %d \n", index, destination[index],
  destination[imageSize + index], destination[imageSize*2 + index],
  destination[imageSize*3 + index] );
    const int yp1 = index / imageSize;
    const int xp1 = index - yp1*imageSize;
    const int yp2 = ((imageSize-1) + index*imageSize) / imageSize;
    const int xp2 = ((imageSize-1) + index*imageSize) - yp2*imageSize;
    const int yp3 = (maxIndex - index) / imageSize;
    const int xp3 = (maxIndex - index) - yp3*imageSize;
    const int yp4 = (maxIndex - imageSize + 1 - index*imageSize) / imageSize;
    const int xp4 = (maxIndex - imageSize + 1 - index*imageSize) -
  yp4*imageSize;
    printf("values: %d: %d %d, %d %d, %d %d, %d %d\n", index, xp1, yp1, xp2,
  yp2, xp3, yp3, xp4, yp4);
  }*/
}

Apollonius::Apollonius(std::shared_ptr<CudaArrayProvider> distancesImage,

  {
    float4 seed = labelsSeed[index];
    const uint cindex = int(seed.y) + int(seed.z) * imageSize;

    if (extractedIndices.find(cindex) != extractedIndices.end())
    {
      if (seed.x > 0)
      {
        seed.x = -seed.x;
        labelsSeed[index] = seed;
      }
    }
  }

  seedBuffer = labelsSeed;
