Example #1
0
def get_bboxes(union_bbox,
               chunk_size,
               overlap=(0, 0, 0),
               back_shift_small=False,
               backend='cloudvolume'):
    '''Use ffn subbox calculator to generate sequential overlapping bboxes'''
    if isinstance(union_bbox, Bbox):
        ffn_style_bbox = bounding_box.BoundingBox(np.array(union_bbox.minpt),
                                                  np.array(union_bbox.size3()))
    else:
        ffn_style_bbox = union_bbox

    calc = bounding_box.OrderlyOverlappingCalculator(
        outer_box=ffn_style_bbox,
        sub_box_size=chunk_size,
        overlap=overlap,
        include_small_sub_boxes=True,
        back_shift_small_sub_boxes=back_shift_small)
    bbs = list(calc.generate_sub_boxes())
    if backend == 'ffn':
        pass
    elif backend == 'cloudvolume':
        bbs = [Bbox(a=bb.start, b=bb.start + bb.size) for bb in bbs]
    else:
        raise ValueError('Use either ffn or cloudvolume')
    return bbs
Example #2
0
def get_chunk_bboxes(union_bbox, chunk_size):
  ffn_style_bbox = bounding_box.BoundingBox(
    np.array(union_bbox.minpt), np.array(union_bbox.size3()))

  calc = bounding_box.OrderlyOverlappingCalculator(
    outer_box=ffn_style_bbox, 
    sub_box_size=chunk_size, 
    overlap=[0,0,0], 
    include_small_sub_boxes=True,
    back_shift_small_sub_boxes=False)
  bbs = [ffn_bb for ffn_bb in calc.generate_sub_boxes()]
  for ffn_bb in bbs:
    logging.warning('sub_bb: %s', ffn_bb)
  return bbs
Example #3
0
def divide_bounding_box(bbox, subvolume_size, overlap):
    """divide up into valid subvolumes."""
    # deal with parsed bbox missing "end" attr
    start = geom_utils.ToNumpy3Vector(bbox.start)
    size = geom_utils.ToNumpy3Vector(bbox.size)

    bbox = bounding_box.BoundingBox(start, size)

    calc = bounding_box.OrderlyOverlappingCalculator(
        outer_box=bbox,
        sub_box_size=subvolume_size,
        overlap=overlap,
        include_small_sub_boxes=True,
        back_shift_small_sub_boxes=False)

    return [bb for bb in calc.generate_sub_boxes()]
Example #4
0
def get_chunk_bboxes(union_bbox,
                     chunk_size,
                     overlap,
                     include_small_sub_boxes=True,
                     back_shift_small_sub_boxes=False):
    ffn_style_bbox = bounding_box.BoundingBox(np.array(union_bbox.minpt),
                                              np.array(union_bbox.size2()))

    calc = bounding_box.OrderlyOverlappingCalculator(
        outer_box=ffn_style_bbox,
        sub_box_size=chunk_size,
        overlap=overlap,
        include_small_sub_boxes=include_small_sub_boxes,
        back_shift_small_sub_boxes=back_shift_small_sub_boxes)

    bbs = [ffn_to_cv(ffn_bb) for ffn_bb in calc.generate_sub_boxes()]

    return bbs