Exemplo n.º 1
0
def test_s2a(ds, group=2, start=0):
    from rhizoscan.root.graph.to_tree import make_tree
    from rhizoscan.root.graph.to_tree import set_downward_segment
    from rhizoscan import geometry as geo

    d1 = ds[group][start]
    d2 = ds[group][start + 1]
    d1.load()
    d2.load()
    g1 = d1.graph
    g2 = d2.graph
    t1 = make_tree(g1)

    T = geo.dot(geo.inv(d1.image_transform), d2.image_transform)

    # set graph into the same frame as tree
    # -------------------------------------
    g2 = g2.copy()
    g2.node = g2.node.copy()
    g2.node.position = geo.transform(T=T, coordinates=g2.node.position)
    g2.segment = g2.segment.copy()  # copy with transformed _node_list
    g2.segment._node_list = g2.node  #    maybe not useful...

    return (t1, g2, T) + seg_to_axe_distance(t1, g2)

    g2 = set_downward_segment(g2)  ## for debug visualisation
    t2 = axe_projection(t1, g2, T)
Exemplo n.º 2
0
def track_plate(sequence, step=1, stand=False):
    """
    ##Obsolete
    warning: since implementation find_plate changed fitting direction => NOT WORKING
    """
    import matplotlib.pyplot as plt

    if isinstance(sequence, basestring):
        import glob
        sequence = glob.glob(sequence)

    plt.ion()
    plt.gray()
    for f in sequence:
        img = _pad(_Image(f, color='gray', format='f'),
                   200,
                   200,
                   fill_value='nearest')
        H = find_plate(img,
                       border=0.06,
                       plate_width=1200,
                       fit='homography',
                       white_stand=stand)
        im = _geo.transform(img, H, ((0, 1200 + 1, step), (0, 1200 + 1, step)))
        plt.imshow(im, hold=0)

        k = raw_input(" 'q' to quit':")
        if k == 'q': break
Exemplo n.º 3
0
def correction_projection(p,i, box_size):
    from rhizoscan import geometry as geo

    Y,X = np.mgrid[map(lambda x: slice(x+1),p.cluster[0].shape)]
    x,y = box_size*geo.transform(T=p.transform[0],coordinates=(X,Y))  # to 125mm square box
    
    du = (np.diff(x[:-1,:],axis=1)**2 + np.diff(y[:-1,:],axis=1)**2)**.5
    dv = (np.diff(x[:,:-1],axis=0)**2 + np.diff(y[:,:-1],axis=0)**2)**.5
    
    return du, dv
Exemplo n.º 4
0
 def E(T):
     return _np.sum(
         _geo.transform(dmap, T=_np.reshape(T, (3, 3)),
                        coordinates=ind))
Exemplo n.º 5
0
 def E(T):
     return _np.sum(
         _geo.transform(dmap, T=rigid(*T), coordinates=ind, cval=1))