コード例 #1
0
def supp_from_connectivity(graph, nlevels):
    nodes = lib.flatten(graph)
    sh = nodes[0].labels.shape
    new_shape = [nlevels] + list(sh)
    out = lib.memsafe_arr(new_shape, _dtype_) * 0.0
    for n in nodes:
        out[n.level][n.labels > 0] = 1.0
    return out
コード例 #2
0
def deblend_all(objects, coefs, min_scales=2):
    """Deblend all objects, each object being represented as a root `MVMNode`.

    Parameters:
      - `objects`: (`list` of `MVMNode` instances) -- root nodes
      - `coefs`: (`list`) -- a list of atrous wavelet coefficients
      - `min_scales`: (`int`) -- minimum number of scales an object should have

    Returns:
      - a list of deblended objests, represented by the root `MVMNode` instances.

    """
    roots = lib.flatten([deblend_node(o, coefs) for o in objects])
    return [r for r in roots if nscales(r) >= min_scales]
コード例 #3
0
def connect_framewise_objs(objlist, testfn=recobjs_overlap, nnext=3):
    for j, frame in enumerate(objlist[:-nnext]):
        nextframes = objlist[j + 1:j + nnext + 1]
        for obj in frame:
            full = embedded_to_full(obj.obj)

            #test1 = lambda o: testfn(full, embedded_to_full(o.obj))
            def test1(o):
                return testfn(full, embedded_to_full(o.obj))

            for nf in nextframes:
                nx = filter(test1, nf)
                if len(nx):
                    for n in nx:
                        obj.linknext(n)
                    break
    objs = [o for o in lib.flatten(objlist) if len(o.prev) or len(o.branches)]
    objs = prune_multiple_prevs(objs)
    return roots_only(objs)
コード例 #4
0
def flat_tree(root_node):
    """Flatten the tree of MVM nodes"""
    acc = [root_node]
    for node in root_node.branches:
        acc.append(flat_tree(node))
    return lib.flatten(acc)