Пример #1
0
def test_jug_execute_simple():
    N = 1024
    random.seed(232)
    A = [False for i in range(N)]

    def setAi(i):
        A[i] = True

    setall = [Task(setAi, i) for i in range(N)]
    store = dict_store()
    jug.task.Task.store = store
    simple_execute()
    assert False not in A
    assert max(store.counts.values()) < 4
Пример #2
0
def test_jug_invalidate():
    def setAi(i):
        A[i] = True
    N = 1024
    A = [False for i in range(N)]
    setall = [Task(setAi, i) for i in range(N)]
    store = dict_store()
    jug.task.Task.store = store
    for t in setall: t.run()

    opts = Options(default_options)
    opts.invalid_name = setall[0].name
    jug.subcommands.invalidate.invalidate(store, opts)
    assert not list(store.store.keys()), list(store.store.keys())
    jug.task.Task.store = dict_store()
Пример #3
0
def test_jug_execute_deps():
    N = 256
    random.seed(234)
    A = [False for i in range(N)]
    def setAi(i, other):
        A[i] = True
    idxs = list(range(N))
    random.shuffle(idxs)
    prev = None
    for idx in idxs:
        prev = Task(setAi, idx, prev)
    store = dict_store()
    jug.task.Task.store = store
    simple_execute()
    assert False not in A
    assert max(store.counts.values()) < 5
_compare('mean_t',mean_t,refs)
_compare('rc_t',rc_t,refs)
#_compare('watershed:direct',water_direct,refs)
#_compare('watershed:gradient',water_gradient,refs)
#_compare('watershed:direct_rc',water_direct_rc,refs)
#_compare('watershed:gradient_rc',water_gradient_rc,refs)
_compare('watershed:direct_mean',water_direct_mean,refs)
_compare('watershed:gradient_mean',water_gradient_mean,refs)
#_compare('watershed:direct_raw',water_direct_raw,refs)
#_compare('watershed:gradient_raw',water_gradient_raw,refs)
#_compare('watershed:direct:full',water_direct,refs_full)
#_compare('watershed:gradient:full',water_gradient,refs_full)
#_compare('watershed:direct_raw:full',water_direct_raw,refs_full)
#_compare('watershed:gradient_raw:full',water_gradient_raw,refs_full)
#_compare('active_masks',active_masks,refs)
_compare('active_masks:filtered',active_masks_filtered,refs)
#_compare('active_masks2',active_masks2,refs)
#_compare('roysam',roysams,refs)
_compare('roysam_mean',roysams_mean,refs)
#_compare('roysams_mean_filter',roysams_mean_filtered,refs)
_compare('roysams_mean_filter_no_AS',roysams_mean_filtered[5:],refs[5:])


aabid_refs = ic100_ref[:5] + gnf_ref[:5]
aabids = [Task(load_aabid,'ic100',i) for i in xrange(5)] +\
         [Task(load_aabid,'gnf',i) for i in xrange(5)]
compare(aabid_refs,ic100_ref[:5],'AS',aabids)


# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
Пример #5
0
    return _process_B(B)

def _process_B(B):
    L,N = ndimage.label(~B)
    bg = 0
    bg_size = (L==bg).sum()
    for i in xrange(1,N+1):
        i_size = (L == i).sum()
        if i_size > bg_size:
            bg_size = i_size
            bg = i
        if i_size < _min_obj_size:
            L[L==i] = 0 
    L[L==bg]=0
    L,_ = ndimage.label(L!=0)
    return L


def load_aabid(col,id):
    from readmagick import readimg
    id = ('../data/images/segmented-ashariff/%s/dna-%s.psd' % (col,id))
    I = readimg(id)
    B = (I[:,:,0] > I[:,:,1])
    return _process_B(B)

ic100_imgs = load_ic100()
gnf_imgs = load_gnf()

ic100_ref = [Task(load_ref,'ic100',i) for i in ic100_idxs]
gnf_ref = [Task(load_ref,'gnf',i) for i in gnf_idxs]