Beispiel #1
0
def main(args):
    substack = SubStack(args.indir,args.substack_id)
    patch = substack.get_volume()
    histogram = np.histogram(patch, bins=256,range=(0,256))[0]
    thresholds = threshold.multi_kapur(histogram, 2)
    outfile=args.outdir+'/'+args.substack_id+'/'+basename(args.indir)
    mkdir_p(args.outdir+'/'+args.substack_id)
    f=open(outfile,'w')
    f.write(str(thresholds[0])+','+str(thresholds[1])+'\n')
    f.close()
Beispiel #2
0
def main(args):
    substack = SubStack(args.indir, args.substack_id)
    patch = substack.get_volume()
    histogram = np.histogram(patch, bins=256, range=(0, 256))[0]
    thresholds = threshold.multi_kapur(histogram, 2)
    outfile = args.outdir + '/' + args.substack_id + '/' + basename(args.indir)
    mkdir_p(args.outdir + '/' + args.substack_id)
    f = open(outfile, 'w')
    f.write(str(thresholds[0]) + ',' + str(thresholds[1]) + '\n')
    f.close()
Beispiel #3
0
def max_entropy(data):
    from bcfind.threshold import multi_kapur
    N = 256
    histogram = [0]*N
    Min = min(data)
    Max = max(data)
    norm_data = [(d-Min)/(Max-Min) for d in data]
    for d in norm_data:
        histogram[int(d*(N-1))] += 1
    t = multi_kapur(histogram,2)[0]
    return Min+(t/float(N-1))*(Max-Min)
Beispiel #4
0
def max_entropy(data):
    from bcfind.threshold import multi_kapur
    N = 256
    histogram = [0]*N
    Min = min(data)
    Max = max(data)
    norm_data = [(d-Min)/(Max-Min) for d in data]
    for d in norm_data:
        histogram[int(d*(N-1))] += 1
    t = multi_kapur(histogram,2)[0]
    return Min+(t/float(N-1))*(Max-Min)
def get_visible_pairs(base_indir,substack_id,view_ids,lower_threshold=30.):
   
    num_vis=0
    for view_id in view_ids:
	substack = SubStack(base_indir+'/'+view_id,args.substack_id)
	patch = substack.get_volume()
	histogram = np.histogram(patch, bins=256,range=(0,256))[0]
	thresholds = threshold.multi_kapur(histogram, 2)
	if thresholds[1]>=lower_threshold:
	    num_vis+=1
    threshold_0=thresholds[0]
    threshold_1=thresholds[1]
    threshold_2=thresholds[2]
    threshold_3=thresholds[3]
   
    list_views=[]
    if num_vis==0:
        return list_views
    elif num_vis==1:
        if threshold_0>=lower_threshold:
                list_views.append(tuple((view_ids[0],view_ids[1])))
                list_views.append(tuple((view_ids[0],view_ids[3])))
        if threshold_1>=lower_threshold:
                list_views.append(tuple((view_ids[0],view_ids[1])))
                list_views.append(tuple((view_ids[2],view_ids[1])))
        if threshold_2>=lower_threshold:
                list_views.append(tuple((view_ids[2],view_ids[1])))
                list_views.append(tuple((view_ids[2],view_ids[3])))
        if threshold_3>=lower_threshold:
                list_views.append(tuple((view_ids[0],view_ids[3])))
                list_views.append(tuple((view_ids[2],view_ids[3])))
    elif num_vis==2:
        if (threshold_0>=lower_threshold and threshold_2>=lower_threshold) or (threshold_1>=lower_threshold and threshold_3>=lower_threshold):
            list_views.append(tuple((view_ids[0],view_ids[1])))
            list_views.append(tuple((view_ids[0],view_ids[3])))
            list_views.append(tuple((view_ids[2],view_ids[1])))
            list_views.append(tuple((view_ids[2],view_ids[3])))
        elif threshold_0>=lower_threshold and threshold_1>=lower_threshold:
            list_views.append(tuple((view_ids[0],view_ids[1])))
        elif threshold_0>=lower_threshold and threshold_3>=lower_threshold:
            list_views.append(tuple((view_ids[0],view_ids[3])))
        elif threshold_2>=lower_threshold and threshold_1>=lower_threshold:
            list_views.append(tuple((view_ids[2],view_ids[1])))
        elif threshold_2>=lower_threshold and threshold_3>=lower_threshold:
            list_views.append(tuple((view_ids[2],view_ids[3])))
    elif num_vis==3:
        if threshold_0 < lower_threshold:
            list_views.append(tuple((view_ids[2],view_ids[1])))
            list_views.append(tuple((view_ids[2],view_ids[3])))
        elif threshold_2 < lower_threshold:
            list_views.append(tuple((view_ids[0],view_ids[1])))
            list_views.append(tuple((view_ids[0],view_ids[3])))
        elif threshold_1 < lower_threshold or threshold_3 < lower_threshold:
            list_views.append(tuple((view_ids[0],view_ids[1])))
            list_views.append(tuple((view_ids[0],view_ids[3])))
            list_views.append(tuple((view_ids[2],view_ids[1])))
            list_views.append(tuple((view_ids[2],view_ids[3])))
    elif num_vis==4:
        list_views.append(tuple((view_ids[0],view_ids[1])))
        list_views.append(tuple((view_ids[0],view_ids[3])))
        list_views.append(tuple((view_ids[2],view_ids[1])))
        list_views.append(tuple((view_ids[2],view_ids[3])))
    return list_views
def get_visible_pairs(base_indir, substack_id, view_ids, lower_threshold=30.):

    num_vis = 0
    for view_id in view_ids:
        substack = SubStack(base_indir + '/' + view_id, args.substack_id)
        patch = substack.get_volume()
        histogram = np.histogram(patch, bins=256, range=(0, 256))[0]
        thresholds = threshold.multi_kapur(histogram, 2)
        if thresholds[1] >= lower_threshold:
            num_vis += 1
    threshold_0 = thresholds[0]
    threshold_1 = thresholds[1]
    threshold_2 = thresholds[2]
    threshold_3 = thresholds[3]

    list_views = []
    if num_vis == 0:
        return list_views
    elif num_vis == 1:
        if threshold_0 >= lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[1])))
            list_views.append(tuple((view_ids[0], view_ids[3])))
        if threshold_1 >= lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[1])))
            list_views.append(tuple((view_ids[2], view_ids[1])))
        if threshold_2 >= lower_threshold:
            list_views.append(tuple((view_ids[2], view_ids[1])))
            list_views.append(tuple((view_ids[2], view_ids[3])))
        if threshold_3 >= lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[3])))
            list_views.append(tuple((view_ids[2], view_ids[3])))
    elif num_vis == 2:
        if (threshold_0 >= lower_threshold and threshold_2 >= lower_threshold
            ) or (threshold_1 >= lower_threshold
                  and threshold_3 >= lower_threshold):
            list_views.append(tuple((view_ids[0], view_ids[1])))
            list_views.append(tuple((view_ids[0], view_ids[3])))
            list_views.append(tuple((view_ids[2], view_ids[1])))
            list_views.append(tuple((view_ids[2], view_ids[3])))
        elif threshold_0 >= lower_threshold and threshold_1 >= lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[1])))
        elif threshold_0 >= lower_threshold and threshold_3 >= lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[3])))
        elif threshold_2 >= lower_threshold and threshold_1 >= lower_threshold:
            list_views.append(tuple((view_ids[2], view_ids[1])))
        elif threshold_2 >= lower_threshold and threshold_3 >= lower_threshold:
            list_views.append(tuple((view_ids[2], view_ids[3])))
    elif num_vis == 3:
        if threshold_0 < lower_threshold:
            list_views.append(tuple((view_ids[2], view_ids[1])))
            list_views.append(tuple((view_ids[2], view_ids[3])))
        elif threshold_2 < lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[1])))
            list_views.append(tuple((view_ids[0], view_ids[3])))
        elif threshold_1 < lower_threshold or threshold_3 < lower_threshold:
            list_views.append(tuple((view_ids[0], view_ids[1])))
            list_views.append(tuple((view_ids[0], view_ids[3])))
            list_views.append(tuple((view_ids[2], view_ids[1])))
            list_views.append(tuple((view_ids[2], view_ids[3])))
    elif num_vis == 4:
        list_views.append(tuple((view_ids[0], view_ids[1])))
        list_views.append(tuple((view_ids[0], view_ids[3])))
        list_views.append(tuple((view_ids[2], view_ids[1])))
        list_views.append(tuple((view_ids[2], view_ids[3])))
    return list_views