ParticleDetection.reconstruct_3D.visualization

Collection of plotting functions to evaluate automatic 3D rod position reconstruction from images of a stereocamera system.

Authors: Adrian Niemann (adrian.niemann@ovgu.de)

Date: 01.11.2022

animate_3D(data: ndarray, comparison: ndarray | None = None, show: bool = True) None | Figure[source]

Create/show an animation of rods in 3D with/out a comparison dataset.

The data will be plotted in blue and the comparison in green.

Parameters:
  • data (np.ndarray) –

    3D coordinates of rods over multiple frames.

    Dimensions: [frame, particle, 3, 2]

  • comparison (np.ndarray, optional) –

    3D coordinates of comparison rods over the same frames as data.

    Dimensions: [frame, particle, 3, 2]

    By default None.

  • show (bool, optional) –

    Flag, whether to show the figure immediately or to return it instead.

    Default is True.

Returns:

None | Figure – Returns the figure only, if show was set to False.

compare_diplacements(data: List[ndarray], labels: List[str] | None = None, show: bool = True) None | Figure[source]

Compare the frame-wise, average displacement between multiple datasets.

From the 3D positions of rods the between frames displacement is calculated for each of the given rods. Both rod endpoint combinations are used to calculate the displacement and the respective minimum is chosen for plotting. The resulting plot then consists of the average displacement for of the given ‘datasets’.

Parameters:
  • data (List[ndarray]) – Dimensions: [dataset, frame, particle, coordinate(3), endpoint(2)]

  • labels (List[str], optional) –

    List of names/IDs for the datasets given.

    By default None.

  • show (bool, optional) –

    Flag, whether to show the figure immediately or to return it instead.

    Default is True.

Returns:

None | Figure – Returns the figure only, if show was set to False.

displacement_fwise(data_3d: ndarray, frames: Iterable[int] | None = None, show: bool = True) None | Figure[source]

Plot the frame-wise (minimum) displacement per rod and average of rods.

From the 3D positions of rods the between frames displacement is calculated for each of the given rods. Both rod endpoint combinations are used to calculate the displacement and the respective minimum is chosen for plotting. The resulting plot then consists of one line per given particle, as well as, the average displacement of all particles between the frames.

Parameters:
  • data_3d (ndarray) – Dimensions: [frame, particle, coordinate(3), endpoint(2)]

  • show (bool, optional) –

    Flag, whether to show the figure immediately or to return it instead.

    Default is True.

Returns:

None | Figure – Returns the figure only, if show was set to False.

length_hist(rod_lengths: ndarray) Figure[source]

Plot a histogram of rod lengths (after the matching process).

Parameters:

rod_lengths (ndarray)

Returns:

Figure

match_nd(weights: ndarray, whr: Tuple[ndarray], show: bool = True) None | Figure[source]

Plot the result npartite_matching() as all nodes with edges between the matched nodes.

Parameters:
  • weights (ndarray) –

    Multidimensional weight matrix used for ND_matching.

    Example dimensions (dictates whr dimensions):

    1. [12, 4, 8]

    2. [12, 12, 12, 48]

  • whr (Tuple[ndarray]) –

    Output of the npartite_matching() process, i.e. the matched indeces per dimension.

    Example dimensions (see weights dimensions):

    1. (4, 4, 4) -> tuple of 3 arrays with len=4

    2. (12, 12, 12, 12) -> tuple of 4 arrays with len=12

  • show (bool, optional) –

    Flag, whether to show the figure immediately or to return it instead.

    Default is True.

Returns:

None | Figure – Returns the figure only, if show was set to False.

matching_results(reprojection_errors: ndarray, rod_lengths: ndarray, show: bool = True) None | Tuple[Figure][source]

Plot the reprojection errors and rod lengths after the matching process.

Plots histograms for the rod endpoint reprojection errors and the rod lengths, especially for evaluation of a rod matching process.

Parameters:
  • reprojection_errors (np.ndarray)

  • rod_lengths (np.ndarray)

  • show (bool, optional) –

    Flag, whether to show the figure immediately or to return it instead.

    Default is True.

Returns:

None | Tuple[Figure] – Returns the figures only, if show was set to False.

[0]: reprojection errors histogram

[1]: rod lengths histogram

reprojection_errors_hist(reprojection_errors: ndarray) Figure[source]

Plot a histogram of reprojection errors (after the matching process).

Parameters:

reprojection_errors (ndarray)

Returns:

Figure

set_tk_tcl_paths() None[source]

Mitigate issue with not found Tkinter.

Uses the workaround shown in the python issue describing Tkinter being unable to find a usable init.tcl. For further information see the original issue: https://github.com/python/cpython/issues/111754

show_3D(data: ndarray, comparison: ndarray | None = None, show: bool = True) None | Figure[source]

Create/show a plot of rods in 3D with/without a comparison dataset.

The data will be plotted in blue and the comparison in green. Right and Left can control the displayed frame.

Parameters:
  • data (ndarray) –

    3D coordinates of rods over multiple frames.

    Dimensions: [frame, 3, 2]

  • comparison (np.ndarray, optional) –

    3D coordinates of comparison rods over the same frames as data.

    Dimensions: [frame, 3, 2]

    By default None.

  • show (bool, optional) –

    Flag, whether to show the figure immediately or to return it instead.

    Default is True.

Returns:

None | Figure – Returns the figure only, if show was set to False.