Process MTG#

class openalea.plantscan3d.processmtg.Line(position, direction, extend)[source]#

Bases: object

Internal class to represent a line with ‘position’, ‘direction’ and ‘extend’ attributes.

static estimate(positions)[source]#

Method to estimate a line from a list of points.

openalea.plantscan3d.processmtg.angle(direction, refdir=(0, 0, 1))[source]#

Determine the angle between a direction and a reference direction (in degrees).

openalea.plantscan3d.processmtg.axis_chord_length(g, n)[source]#

Determine the chord length of the axis.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed.

  • n (int) – Node id.

Return type:

The chord length of an axis.

openalea.plantscan3d.processmtg.axis_extremities(g, n)[source]#

Determine the extremities of an axis.

openalea.plantscan3d.processmtg.axis_extremities_angle(g, n, refdir=(0, 0, 1))[source]#

Determine the angle between a reference direction and the extremities of an axis.

openalea.plantscan3d.processmtg.axis_length(g, n)[source]#

Determine the length of the axis.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed.

  • n (int) – Node id.

Return type:

The length of the axis.

openalea.plantscan3d.processmtg.axis_nodes_normedposition(g, axisroot)[source]#

Compute the normalized position of each node along an axis.

Parameters:
  • g (openalea.mtg.MTG) – MTG object.

  • axisroot (int) – Root node of the axis to compute positions for.

Returns:

List of (node_id, normalized_position) where normalized_position is the cumulative length from the axis root divided by the total axis length. The parent of the axis root is prepended with position 0 if it exists.

Return type:

list of tuple

openalea.plantscan3d.processmtg.axis_subpart(g, axisroot, beglengthratio, endlengthratio)[source]#

Extract a subpart of an axis.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed, on which to determine the trunk radius.

  • axisroot (int) – Node id to determine the axis.

  • beglengthratio (float) – Ratio of the length of the subpart to extract to the beginning of the axis.

  • endlengthratio (float) – Ratio of the length of the subpart to extract to the end of the axis.

Return type:

List of node ids of the subpart of the axis.

openalea.plantscan3d.processmtg.axis_subpart_angle(g, axisroot, beglengthratio, endlengthratio, refdir=(0, 0, 1))[source]#

Determine the angle between a subpart of an axis and a reference direction.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed, on which to determine the trunk radius.

  • axisroot (int) – Node id to determine the axis.

  • beglengthratio (float) – Ratio of the length of the subpart to extract to the beginning of the axis.

  • endlengthratio (float) – Ratio of the length of the subpart to extract to the end of the axis.

  • refdir (Vector3) – Reference direction.

Return type:

Angle (in degrees) between the subpart of the axis and the reference direction.

openalea.plantscan3d.processmtg.characterize_mtg(g)[source]#

Function to characterize a MTG object.

Parameters:

g (openalea.mtg.MTG) – MTG object to be characterized

Returns:

  • trunk_length : length of the trunk

  • trunk_branching_zone_start : start of the trunk branching zone

  • trunk_branching_zone_end : end of the trunk branching zone

  • trunk_branching_zone_length : length of the trunk branching zone

  • trunk_base_radius : base radius of the trunk

  • trunk_top_radius : top radius of the trunk

  • nb_short_axis : number of short lateral axis

  • nb_long_axis : number of long lateral axis

Return type:

Dictionary of results

openalea.plantscan3d.processmtg.determine_radius(g, points, maxmethod=True, radiusproperty='radius')[source]#

Function to determine the radius of each node of a MTG object.

Parameters:
  • g (openalea.mtg.MTG) – mtg object. Usually, the skeleton of the point cloud.

  • points (PointSet) – PointSet of the point cloud.

  • maxmethod (bool) – Wether to use the max (True) or the mean (False) method to estimate the radius. Default is True.

  • radiusproperty (str) – Name of the property in the mtg to store the radius. Default is “radius”.

openalea.plantscan3d.processmtg.generate_mtg(filename, do_filter_points=True, do_gaussian_filter=True, do_determine_radius=True, do_pipemodel=True, **kwargs)[source]#

Summary function that generates a MTG from a point cloud.

Parameters:
  • filename (str) – Filename of the point cloud.

  • do_filter_points (bool) – If True, points are filtered to keep only points with a density above a threshold. Default to True.

  • do_gaussian_filter (bool) – If True, a gaussian filter is applied to the position property of the mtg. Default to True.

  • do_determine_radius (bool) – If True, the radius of each node is estimated. Default to True.

  • do_pipemodel (bool) – If True, the pipe model is applied to correct the radius of each node. Default to True.

  • kwargs – additional arguments to pass to the inner functions

Returns:

mtg object representing the point cloud with a skeleton and radius estimation for each node.

Return type:

openalea.mtg.MTG

Notes

generate_mtg is a wrapper around the following functions (in that order):

Arguments passed to the inner functions can be passed as keyword arguments to generate_mtg.

Example

>>> mtg = generate_mtg("path/to/pointcloud.pts")
>>> mtg = generate_mtg("path/to/pointcloud.pts",
            gaussian_filter=False,
            subsample={"ptsnb": 1000},
            filter_points={"densityfilterratio": 0.05, "densityradius": 0.1, "k": 20},
            skeleton={"skel_func": adaptivespacecolonization_method, "asc_max_growth_lengt": 0.01},
            determine_radius={"radiusproperty": "Radii", "maxmethod": False}
            )
openalea.plantscan3d.processmtg.lateral_children(g, vid)[source]#

Returns a list of the lateral children of a node.

openalea.plantscan3d.processmtg.nb_lateral_children(g, vid)[source]#
openalea.plantscan3d.processmtg.node_length(g, n)[source]#

Determine the length of the node.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed.

  • n (int) – Node id.

Return type:

The length between a node and his parent.

openalea.plantscan3d.processmtg.node_position(g, n)[source]#

Retuns the position of a node in a MTG.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed, on which to determine the trunk radius.

  • n (int) – Index of the node.

Return type:

Tupole of the position of the node (x,y,z).

openalea.plantscan3d.processmtg.retrieve_axis_radii(g, vid)[source]#

Determine the radius of the axis: radius of the first node, radius of the last node and mean value of the radius of the axis.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed.

  • n (int) – Node id.

Return type:

Tuple of the radius of the first node, mean value of the radius of the axis and radius of the last node.

openalea.plantscan3d.processmtg.trunk_branching_zone_end(g)[source]#

Determine the end of the trunk branching zone.

Parameters:

g (openalea.mtg.MTG) – MTG object reconstructed.

Return type:

The length of the trunk from bottom to the end of the branching zone.

openalea.plantscan3d.processmtg.trunk_branching_zone_length(g)[source]#

Determine the length of the trunk’s branching zone.

Parameters:

g (openalea.mtg.MTG) – MTG object reconstructed.

Return type:

The length of the trunk’s branching zone.

openalea.plantscan3d.processmtg.trunk_branching_zone_start(g)[source]#

Detemine the start of the trunk branching zone.

Parameters:

g (openalea.mtg.MTG) – MTG object reconstructed.

Return type:

The length of the trunk from bottom to the start of the branching zone.

openalea.plantscan3d.processmtg.trunk_direction(g, trunkratio=1)[source]#

Determine the direction of the trunk.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed, on which to determine the trunk direction.

  • trunkratio (float) – Ratio of the trunk length to the total length of the trunk.

Return type:

A list of Vector3 objects representing the direction of the trunk.

openalea.plantscan3d.processmtg.trunk_lateral_axes(g, length_threshold=0.05)[source]#

Returns the trunk lateral axes. Two lists are returned, the first one is the short axes, the second one is the long axes.

Parameters:
  • g (openalea.mtg.MTG) – MTG object

  • length_threshold (float) – minimum length of long lateral axis

Returns:

shortaxis, longaxis – list of lateral axis nodes. Short axis if smaller than length_threshold, long otherwise.

Return type:

list

openalea.plantscan3d.processmtg.trunk_length(g)[source]#

Determine the length of the trunk.

Parameters:

g (openalea.mtg.MTG) – MTG object reconstructed.

Return type:

The length of the trunk.

openalea.plantscan3d.processmtg.trunk_nodes(g)[source]#

Returns the nodes of the trunk.

openalea.plantscan3d.processmtg.trunk_radii(g, begratio=0.1, endratio=0.1)[source]#

Determine the radius of the trunk at the base and the top.

Parameters:
  • g (openalea.mtg.MTG) – MTG object reconstructed, on which to determine the trunk radius.

  • begratio (float) – Ratio of the bottom of the trunk used to determine the bottom radius. Default to 0.1.

  • endratio (float) – Ratio of the top of the trunk used to determine the top radius. Default to 0.1.

Return type:

Tuple of the bottom and top radius of the trunk.

openalea.plantscan3d.processmtg.trunk_root(g)[source]#

Returns the root node of the trunk.