def main():
    args = process_command_line()

    with open(args.bounding_box_file, 'r') as f:
        bb_str = f.readline()
        bounding_box = bb_str.split(' ')
        bounding_box = [int(x) for x in bounding_box]

    assert len(bounding_box) == 6, "Bounding box needs 6 coordinates!"
    print "Bounding box:", bounding_box

    shape = (bounding_box[1] - bounding_box[0],
            bounding_box[3] - bounding_box[2],
            bounding_box[5] - bounding_box[4] )

    print "Resulting shape:", shape

    print "Reading in skeletons from", args.skeleton_path
    # get the skeleton coordinates first
    skeleton_coordinates = coordinates_from_json(args.skeleton_path, bounding_box)

    # perform dense reconstruction for all skeleton coordinates we have
    print "Projecting skeletons to dense segments"
    dense_skeletons = dense_reconstruction(args.prob_folder,
            skeleton_coordinates, args.rf_path,
            shape)

    # for debugging
    from volumina_viewer import volumina_n_layer
    probs = np.array(np.squeeze(vigra.readVolume(args.prob_folder+"/pmaps_z=000.tif")))
    volumina_n_layer([probs, dense_skeletons.astype(np.uint32)])
Пример #2
0
def vol_to_vol(path):
    vol = vigra.readVolume(path + ".tif")
    vol = vol.squeeze()
    vol = vol.view(np.ndarray)
    #print vol.shape
    #print type(vol)
    return vol
Пример #3
0
def load_feats_and_gt_pedunculus():

    #raw_data = vigra.readHDF5(
    #        "/home/constantin/Work/data_ssd/data_080515/pedunculus/150401pedunculus_middle_512x512_first30_sliced.h5",
    #        "data"
    #        )

    gt = vigra.readVolume(
            "/home/constantin/Work/data_ssd/data_080515/pedunculus/150401_pedunculus_membrane_labeling.tif")
    gt = np.squeeze(gt)

    # delete black slice
    gt = np.delete(gt, 6, axis = 2)

    gt[gt == 0.] = 1
    gt[gt == 255.] = 0
    gt = gt.astype(np.uint32)

    save_path = "/home/constantin/Work/data_ssd/data_080515/pedunculus/features"
    #compute_ilastik_2dfeatures(raw_data, save_path)

    feats_path = os.path.join( save_path, "all_features.h5")
    # make sure that features are computed!
    #feats = load_precomputed_feats(save_path, raw_data.shape)
    #vigra.writeHDF5(feats, feats_path, "data")

    feats = vigra.readHDF5(feats_path, "data")

    return (feats, gt)
Пример #4
0
def gt_pedunculus():
    labels_path = "/home/constantin/Work/data_ssd/data_080515/pedunculus/150401_pedunculus_membrane_labeling.tif"
    raw_path    = "/home/constantin/Work/data_ssd/data_080515/pedunculus/150401pedunculus_middle_512x512_first30_sliced.h5"

    labels = vigra.readVolume(labels_path)

    labels = np.squeeze(labels)
    labels = np.delete(labels, 6, axis = 2)

    raw = vigra.readHDF5(raw_path, "data")

    labels = preprocess_for_bgsmoothing_pedunculus(labels)
    gt = smooth_background(labels).astype(np.uint32)

    volumina_n_layer( (raw, labels, gt) )

    gt_path = "/home/constantin/Work/data_ssd/data_080515/pedunculus/ground_truth_seg.h5"
    vigra.writeHDF5(gt, gt_path, "gt")
Пример #5
0
def project_gt_pedunculus():
    labels_path = "/home/constantin/Work/data_ssd/data_080515/pedunculus/150401_pedunculus_membrane_labeling.tif"
    gt_path     = "/home/constantin/Work/data_ssd/data_080515/pedunculus/gt_mc.h5"
    raw_path    = "/home/constantin/Work/data_ssd/data_080515/pedunculus/150401pedunculus_middle_512x512_first30_sliced.h5"

    labels = vigra.readVolume(labels_path)
    labels = np.squeeze(labels)
    labels = np.delete(labels, 6, axis = 2)

    gt = vigra.readHDF5(gt_path, "gt")
    raw = vigra.readHDF5(raw_path, "data")

    gt = project_gt(labels, gt)

    save_path     = "/home/constantin/Work/data_ssd/data_080515/pedunculus/gt_mc_bkg.h5"

    volumina_n_layer( (raw, gt, labels) )

    vigra.writeHDF5(gt, save_path, "gt")
Пример #6
0
def slices_to_vol(path):
    files = os.listdir(path)
    vol = vigra.readVolume(os.path.join(path, files[0]))
    vol = vol.squeeze()
    vol = vol.view(np.ndarray)
    return vol
def vol_to_vol(path):
    vol = vigra.readVolume( path + ".tif" )
    vol = vol.squeeze()
    vol = vol.view(np.ndarray)
    return vol
Пример #8
0
#    i += 1
#
#
##seg = seg.astype( np.float32 )
##seg /= seg.max()
##seg *= 255.0
#
#print np.unique(seg).size
#print seg.max()
#
#save_path = "/home/constantin/Work/data_ssd/data_080515/pedunculus/res_mc/post_processed/final_mitooff.tif"
#
#vigra.impex.writeVolume( seg, save_path, ''  )

path = "/home/constantin/Desktop/results_for_fred/export_Z=00.png"

#
#for i in range(29):
#    path_im = path + str(i).zfill(2) + ".png"
#    im = vigra.impex.readImage(path_im)
#    vol_save[:,:,:,i] = im.astype(np.uint8)

vol_save = vigra.readVolume(path)

print vol_save.shape

save_path = "/home/constantin/Desktop/results_for_fred/result_mitooff.tif"

vigra.impex.writeVolume( vol_save, save_path, '', dtype = 'UINT16', compression = '' )