Skip to content

refine_skeleton

This program performs refinement of an existing skeleton (in the form of 3D point cloud data) of a plant starting from it's initial "coarse" structure. The coarse skeleton is "rectified" via a stochastic optimization framework, by "pushing" the skeleton points towards the original point cloud data so that they get "aligned" in space. There are two parameters that control the quality of alignment, alpha and beta (denoted as 'myAlpha' and 'myBeta' in 'param_settings.py')

Author: Ayan Chaudhury INRIA team MOSAIC

file_loader(fname) Link

Load point cloud or skeleton from a file.

Source code in skeleton_refinement/cli/refine_skeleton.py
87
88
89
90
91
92
93
94
95
96
97
98
99
def file_loader(fname):
    """Load point cloud or skeleton from a file."""
    if fname.suffix in [".xyz", ".txt"]:
        xyz = load_xyz(fname)
    elif fname.suffix == ".json":
        xyz = load_json(fname, "points")
    elif fname.suffix == ".ply":
        xyz = load_ply(fname)
    elif fname.suffix == ".p":
        xyz = load_nx(fname)
    else:
        raise IOError(f"Unknown input file format '{fname.suffix}' for file '{fname}'! Choose from {IN_FMT}.")
    return xyz

file_writer(fname, skel) Link

Write skeleton to a file.

Source code in skeleton_refinement/cli/refine_skeleton.py
102
103
104
105
106
107
108
109
110
111
112
def file_writer(fname, skel):
    """Write skeleton to a file."""
    if fname.suffix in [".xyz", ".txt"]:
        np.savetxt(fname, skel, delimiter=' ')
    elif fname.suffix == ".json":
        save_json(fname, skel)
    elif fname.suffix == ".p":
        save_nx(fname, skel)
    else:
        raise IOError(f"Unknown output file format {fname.suffix}!")
    return