Esempio n. 1
0
ZObject3dScan ZDvidInfo::getBlockIndex(const ZObject3dScan &obj) const
{
  ZIntPoint gridSize = m_endBlockIndex - m_startBlockIndex + 1;
  size_t area = ((size_t) gridSize.getX()) * gridSize.getY();
  size_t blockNumber = area * gridSize.getZ();
  std::vector<bool> isAdded(blockNumber, false);

  //std::set<ZIntPoint> blockSet;
  //ZIntPointArray blockArray;
  ZObject3dScan blockObj;

  for (size_t i = 0; i < obj.getStripeNumber(); ++i) {
#ifdef _DEBUG_2
    if (i % 10000 == 0) {
      std::cout << i << "/" << obj.getStripeNumber() << std::endl;
    }
#endif
    const ZObject3dStripe &stripe = obj.getStripe(i);
    int y = stripe.getY();
    int z = stripe.getZ();
    if (y > 0 && z > 0 && y < m_startCoordinates[1] + m_stackSize[1] &&
        z < m_startCoordinates[2] + m_stackSize[2]) {
      for (int j = 0; j < stripe.getSegmentNumber(); ++j) {
        int x0 = stripe.getSegmentStart(j);
        int x1 = stripe.getSegmentEnd(j);
        if (x0 < 0) {
          x0 = 0;
        } else if (x0 >= m_startCoordinates[0] + m_stackSize[0]) {
          x0 = m_startCoordinates[0] + m_stackSize[0] - 1;
        }

        if (x1 < 0) {
          x1 = 0;
        } else if (x1 >= m_startCoordinates[0] + m_stackSize[0]) {
          x1 = m_startCoordinates[0] + m_stackSize[0] - 1;
        }

        ZIntPoint block1 = getBlockIndex(x0, y, z);
        size_t blockIndex1 = area * block1.getZ() +
            gridSize.getY() * block1.getY() + block1.getX();
        ZIntPoint block2 = getBlockIndex(x1, y, z);
        size_t blockIndex2 = area * block2.getZ() +
            gridSize.getY() * block2.getY() + block2.getX();

        if (!isAdded[blockIndex1] || !isAdded[blockIndex2]) {
          blockObj.addSegment(
                block1.getZ(), block1.getY(), block1.getX(), block2.getX(), false);
          isAdded[blockIndex1] = true;
          isAdded[blockIndex2] = true;
        }
      }
    }
  }

  //blockArray.append(blockSet.begin(), blockSet.end());
  blockObj.canonize();

  return blockObj;
}
Esempio n. 2
0
ZSwcTree* ZSwcGenerator::createSwc(
    const ZObject3dScan &blockObj, int z, const ZDvidInfo &dvidInfo)
{
#ifdef _FLYEM_
  ZObject3dScan slice = blockObj.getSlice(z);
  size_t stripeNumber = slice.getStripeNumber();

  ZSwcTree *tree = new ZSwcTree;
  for (size_t s = 0; s < stripeNumber; ++s) {
    const ZObject3dStripe &stripe = slice.getStripe(s);
    int nseg = stripe.getSegmentNumber();
    int y = stripe.getY();
    int z = stripe.getZ();
    for (int i = 0; i < nseg; ++i) {
      int x0 = stripe.getSegmentStart(i);
      int x1 = stripe.getSegmentEnd(i);
      for (int x = x0; x <= x1; ++x) {
        ZIntCuboid cuboid = dvidInfo.getBlockBox(x, y, z);
        tree->merge(createBoxSwc(cuboid));
      }
    }
  }

  return tree;
#else
  UNUSED_PARAMETER(&blockObj);
  UNUSED_PARAMETER(z);
  UNUSED_PARAMETER(&dvidInfo);
  return NULL;
#endif
}
Esempio n. 3
0
void ZSparseObject::append(const ZObject3dScan &obj)
{
  for (size_t i = 0; i < obj.getStripeNumber(); ++i) {
    m_stripeArray.push_back(obj.getStripe(i));
  }
}