UnifiedAAMCLMAlgorithmResult

class menpofit.unified_aam_clm.result.UnifiedAAMCLMAlgorithmResult(shapes, shape_parameters, appearance_parameters, initial_shape=None, image=None, gt_shape=None, costs=None)[source]

Bases: ParametricIterativeResult

Class for storing the iterative result of a Unified AAM-CLM optimisation algorithm.

Note

When using a method with a parametric shape model, the first step is to reconstruct the initial shape using the shape model. The generated reconstructed shape is then used as initialisation for the iterative optimisation. This step is not counted in the number of iterations.

Parameters
  • shapes (list of menpo.shape.PointCloud) – The list of shapes per iteration. The first and last members correspond to the initial and final shapes, respectively.

  • shape_parameters (list of (n_shape_parameters,) ndarray) – The list of shape parameters per iteration. The first and last members correspond to the initial and final shapes, respectively.

  • appearance_parameters (list of (n_appearance_parameters,) ndarray) – The list of appearance parameters per iteration. The first and last members correspond to the initial and final shapes, respectively.

  • initial_shape (menpo.shape.PointCloud or None, optional) – The initial shape from which the fitting process started. If None, then no initial shape is assigned.

  • image (menpo.image.Image or subclass or None, optional) – The image on which the fitting process was applied. Note that a copy of the image will be assigned as an attribute. If None, then no image is assigned.

  • gt_shape (menpo.shape.PointCloud or None, optional) – The ground truth shape associated with the image. If None, then no ground truth shape is assigned.

  • costs (list of float or None, optional) – The list of cost per iteration. If None, then it is assumed that the cost function cannot be computed for the specific algorithm.

displacements()

A list containing the displacement between the shape of each iteration and the shape of the previous one.

Type

list of ndarray

displacements_stats(stat_type='mean')

A list containing a statistical metric on the displacements between the shape of each iteration and the shape of the previous one.

Parameters

stat_type ({'mean', 'median', 'min', 'max'}, optional) – Specifies a statistic metric to be extracted from the displacements.

Returns

displacements_stat (list of float) – The statistical metric on the points displacements for each iteration.

Raises

ValueError – type must be ‘mean’, ‘median’, ‘min’ or ‘max’

errors(compute_error=None)

Returns a list containing the error at each fitting iteration, if the ground truth shape exists.

Parameters

compute_error (callable, optional) – Callable that computes the error between the shape at each iteration and the ground truth shape.

Returns

errors (list of float) – The error at each iteration of the fitting process.

Raises

ValueError – Ground truth shape has not been set, so the final error cannot be computed

final_error(compute_error=None)

Returns the final error of the fitting process, if the ground truth shape exists. This is the error computed based on the final_shape.

Parameters

compute_error (callable, optional) – Callable that computes the error between the fitted and ground truth shapes.

Returns

final_error (float) – The final error at the end of the fitting process.

Raises

ValueError – Ground truth shape has not been set, so the final error cannot be computed

initial_error(compute_error=None)

Returns the initial error of the fitting process, if the ground truth shape and initial shape exist. This is the error computed based on the initial_shape.

Parameters

compute_error (callable, optional) – Callable that computes the error between the initial and ground truth shapes.

Returns

initial_error (float) – The initial error at the beginning of the fitting process.

Raises
  • ValueError – Initial shape has not been set, so the initial error cannot be computed

  • ValueError – Ground truth shape has not been set, so the initial error cannot be computed

plot_costs(figure_id=None, new_figure=False, render_lines=True, line_colour='b', line_style='-', line_width=2, render_markers=True, marker_style='o', marker_size=4, marker_face_colour='b', marker_edge_colour='k', marker_edge_width=1.0, render_axes=True, axes_font_name='sans-serif', axes_font_size=10, axes_font_style='normal', axes_font_weight='normal', axes_x_limits=0.0, axes_y_limits=None, axes_x_ticks=None, axes_y_ticks=None, figure_size=(10, 6), render_grid=True, grid_line_style='--', grid_line_width=0.5)

Plot of the cost function evolution at each fitting iteration.

Parameters
  • figure_id (object, optional) – The id of the figure to be used.

  • new_figure (bool, optional) – If True, a new figure is created.

  • render_lines (bool, optional) – If True, the line will be rendered.

  • line_colour (colour or None, optional) –

    The colour of the line. If None, the colour is sampled from the jet colormap. Example colour options are

    {'r', 'g', 'b', 'c', 'm', 'k', 'w'}
    or
    (3, ) ndarray
    

  • line_style ({'-', '--', '-.', ':'}, optional) – The style of the lines.

  • line_width (float, optional) – The width of the lines.

  • render_markers (bool, optional) – If True, the markers will be rendered.

  • marker_style (marker, optional) –

    The style of the markers. Example marker options

    {'.', ',', 'o', 'v', '^', '<', '>', '+', 'x', 'D', 'd', 's',
     'p', '*', 'h', 'H', '1', '2', '3', '4', '8'}
    

  • marker_size (int, optional) – The size of the markers in points.

  • marker_face_colour (colour or None, optional) –

    The face (filling) colour of the markers. If None, the colour is sampled from the jet colormap. Example colour options are

    {'r', 'g', 'b', 'c', 'm', 'k', 'w'}
    or
    (3, ) ndarray
    

  • marker_edge_colour (colour or None, optional) –

    The edge colour of the markers.If None, the colour is sampled from the jet colormap. Example colour options are

    {'r', 'g', 'b', 'c', 'm', 'k', 'w'}
    or
    (3, ) ndarray
    

  • marker_edge_width (float, optional) – The width of the markers’ edge.

  • render_axes (bool, optional) – If True, the axes will be rendered.

  • axes_font_name (See below, optional) –

    The font of the axes. Example options

    {'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
    

  • axes_font_size (int, optional) – The font size of the axes.

  • axes_font_style ({'normal', 'italic', 'oblique'}, optional) – The font style of the axes.

  • axes_font_weight (See below, optional) –

    The font weight of the axes. Example options

    {'ultralight', 'light', 'normal', 'regular', 'book', 'medium',
     'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy',
     'extra bold', 'black'}
    

  • axes_x_limits (float or (float, float) or None, optional) – The limits of the x axis. If float, then it sets padding on the right and left of the graph as a percentage of the curves’ width. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_y_limits (float or (float, float) or None, optional) – The limits of the y axis. If float, then it sets padding on the top and bottom of the graph as a percentage of the curves’ height. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_x_ticks (list or tuple or None, optional) – The ticks of the x axis.

  • axes_y_ticks (list or tuple or None, optional) – The ticks of the y axis.

  • figure_size ((float, float) or None, optional) – The size of the figure in inches.

  • render_grid (bool, optional) – If True, the grid will be rendered.

  • grid_line_style ({'-', '--', '-.', ':'}, optional) – The style of the grid lines.

  • grid_line_width (float, optional) – The width of the grid lines.

Returns

renderer (menpo.visualize.GraphPlotter) – The renderer object.

plot_displacements(stat_type='mean', figure_id=None, new_figure=False, render_lines=True, line_colour='b', line_style='-', line_width=2, render_markers=True, marker_style='o', marker_size=4, marker_face_colour='b', marker_edge_colour='k', marker_edge_width=1.0, render_axes=True, axes_font_name='sans-serif', axes_font_size=10, axes_font_style='normal', axes_font_weight='normal', axes_x_limits=0.0, axes_y_limits=None, axes_x_ticks=None, axes_y_ticks=None, figure_size=(10, 6), render_grid=True, grid_line_style='--', grid_line_width=0.5)

Plot of a statistical metric of the displacement between the shape of each iteration and the shape of the previous one.

Parameters
  • stat_type ({mean, median, min, max}, optional) – Specifies a statistic metric to be extracted from the displacements (see also displacements_stats() method).

  • figure_id (object, optional) – The id of the figure to be used.

  • new_figure (bool, optional) – If True, a new figure is created.

  • render_lines (bool, optional) – If True, the line will be rendered.

  • line_colour (colour or None (See below), optional) –

    The colour of the line. If None, the colour is sampled from the jet colormap. Example colour options are

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • line_style (str (See below), optional) –

    The style of the lines. Example options:

    {-, --, -., :}
    

  • line_width (float, optional) – The width of the lines.

  • render_markers (bool, optional) – If True, the markers will be rendered.

  • marker_style (str (See below), optional) –

    The style of the markers. Example marker options

    {., ,, o, v, ^, <, >, +, x, D, d, s, p, *, h, H, 1, 2, 3, 4, 8}
    

  • marker_size (int, optional) – The size of the markers in points.

  • marker_face_colour (colour or None, optional) –

    The face (filling) colour of the markers. If None, the colour is sampled from the jet colormap. Example colour options are

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • marker_edge_colour (colour or None, optional) –

    The edge colour of the markers. If None, the colour is sampled from the jet colormap. Example colour options are

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • marker_edge_width (float, optional) – The width of the markers’ edge.

  • render_axes (bool, optional) – If True, the axes will be rendered.

  • axes_font_name (str (See below), optional) –

    The font of the axes. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • axes_font_size (int, optional) – The font size of the axes.

  • axes_font_style (str (See below), optional) –

    The font style of the axes. Example options

    {normal, italic, oblique}
    

  • axes_font_weight (str (See below), optional) –

    The font weight of the axes. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • axes_x_limits (float or (float, float) or None, optional) – The limits of the x axis. If float, then it sets padding on the right and left of the graph as a percentage of the curves’ width. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_y_limits (float or (float, float) or None, optional) – The limits of the y axis. If float, then it sets padding on the top and bottom of the graph as a percentage of the curves’ height. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_x_ticks (list or tuple or None, optional) – The ticks of the x axis.

  • axes_y_ticks (list or tuple or None, optional) – The ticks of the y axis.

  • figure_size ((float, float) or None, optional) – The size of the figure in inches.

  • render_grid (bool, optional) – If True, the grid will be rendered.

  • grid_line_style ({'-', '--', '-.', ':'}, optional) – The style of the grid lines.

  • grid_line_width (float, optional) – The width of the grid lines.

Returns

renderer (menpo.visualize.GraphPlotter) – The renderer object.

plot_errors(compute_error=None, figure_id=None, new_figure=False, render_lines=True, line_colour='b', line_style='-', line_width=2, render_markers=True, marker_style='o', marker_size=4, marker_face_colour='b', marker_edge_colour='k', marker_edge_width=1.0, render_axes=True, axes_font_name='sans-serif', axes_font_size=10, axes_font_style='normal', axes_font_weight='normal', axes_x_limits=0.0, axes_y_limits=None, axes_x_ticks=None, axes_y_ticks=None, figure_size=(10, 6), render_grid=True, grid_line_style='--', grid_line_width=0.5)

Plot of the error evolution at each fitting iteration.

Parameters
  • compute_error (callable, optional) – Callable that computes the error between the shape at each iteration and the ground truth shape.

  • figure_id (object, optional) – The id of the figure to be used.

  • new_figure (bool, optional) – If True, a new figure is created.

  • render_lines (bool, optional) – If True, the line will be rendered.

  • line_colour (colour or None (See below), optional) –

    The colour of the line. If None, the colour is sampled from the jet colormap. Example colour options are

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • line_style (str (See below), optional) –

    The style of the lines. Example options:

    {-, --, -., :}
    

  • line_width (float, optional) – The width of the lines.

  • render_markers (bool, optional) – If True, the markers will be rendered.

  • marker_style (str (See below), optional) –

    The style of the markers. Example marker options

    {., ,, o, v, ^, <, >, +, x, D, d, s, p, *, h, H, 1, 2, 3, 4, 8}
    

  • marker_size (int, optional) – The size of the markers in points.

  • marker_face_colour (colour or None, optional) –

    The face (filling) colour of the markers. If None, the colour is sampled from the jet colormap. Example colour options are

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • marker_edge_colour (colour or None, optional) –

    The edge colour of the markers. If None, the colour is sampled from the jet colormap. Example colour options are

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • marker_edge_width (float, optional) – The width of the markers’ edge.

  • render_axes (bool, optional) – If True, the axes will be rendered.

  • axes_font_name (str (See below), optional) –

    The font of the axes. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • axes_font_size (int, optional) – The font size of the axes.

  • axes_font_style (str (See below), optional) –

    The font style of the axes. Example options

    {normal, italic, oblique}
    

  • axes_font_weight (str (See below), optional) –

    The font weight of the axes. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • axes_x_limits (float or (float, float) or None, optional) – The limits of the x axis. If float, then it sets padding on the right and left of the graph as a percentage of the curves’ width. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_y_limits (float or (float, float) or None, optional) – The limits of the y axis. If float, then it sets padding on the top and bottom of the graph as a percentage of the curves’ height. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_x_ticks (list or tuple or None, optional) – The ticks of the x axis.

  • axes_y_ticks (list or tuple or None, optional) – The ticks of the y axis.

  • figure_size ((float, float) or None, optional) – The size of the figure in inches.

  • render_grid (bool, optional) – If True, the grid will be rendered.

  • grid_line_style ({'-', '--', '-.', ':'}, optional) – The style of the grid lines.

  • grid_line_width (float, optional) – The width of the grid lines.

Returns

renderer (menpo.visualize.GraphPlotter) – The renderer object.

reconstructed_initial_error(compute_error=None)

Returns the error of the reconstructed initial shape of the fitting process, if the ground truth shape exists. This is the error computed based on the reconstructed_initial_shape.

Parameters

compute_error (callable, optional) – Callable that computes the error between the reconstructed initial and ground truth shapes.

Returns

reconstructed_initial_error (float) – The error that corresponds to the initial shape’s reconstruction.

Raises

ValueError – Ground truth shape has not been set, so the reconstructed initial error cannot be computed

to_result(pass_image=True, pass_initial_shape=True, pass_gt_shape=True)

Returns a Result instance of the object, i.e. a fitting result object that does not store the iterations. This can be useful for reducing the size of saved fitting results.

Parameters
  • pass_image (bool, optional) – If True, then the image will get passed (if it exists).

  • pass_initial_shape (bool, optional) – If True, then the initial shape will get passed (if it exists).

  • pass_gt_shape (bool, optional) – If True, then the ground truth shape will get passed (if it exists).

Returns

result (Result) – The final “lightweight” fitting result.

view(figure_id=None, new_figure=False, render_image=True, render_final_shape=True, render_initial_shape=False, render_gt_shape=False, subplots_enabled=True, channels=None, interpolation='bilinear', cmap_name=None, alpha=1.0, masked=True, final_marker_face_colour='r', final_marker_edge_colour='k', final_line_colour='r', initial_marker_face_colour='b', initial_marker_edge_colour='k', initial_line_colour='b', gt_marker_face_colour='y', gt_marker_edge_colour='k', gt_line_colour='y', render_lines=True, line_style='-', line_width=2, render_markers=True, marker_style='o', marker_size=4, marker_edge_width=1.0, render_numbering=False, numbers_horizontal_align='center', numbers_vertical_align='bottom', numbers_font_name='sans-serif', numbers_font_size=10, numbers_font_style='normal', numbers_font_weight='normal', numbers_font_colour='k', render_legend=True, legend_title='', legend_font_name='sans-serif', legend_font_style='normal', legend_font_size=10, legend_font_weight='normal', legend_marker_scale=None, legend_location=2, legend_bbox_to_anchor=(1.05, 1.0), legend_border_axes_pad=None, legend_n_columns=1, legend_horizontal_spacing=None, legend_vertical_spacing=None, legend_border=True, legend_border_padding=None, legend_shadow=False, legend_rounded_corners=False, render_axes=False, axes_font_name='sans-serif', axes_font_size=10, axes_font_style='normal', axes_font_weight='normal', axes_x_limits=None, axes_y_limits=None, axes_x_ticks=None, axes_y_ticks=None, figure_size=(7, 7))

Visualize the fitting result. The method renders the final fitted shape and optionally the initial shape, ground truth shape and the image, id they were provided.

Parameters
  • figure_id (object, optional) – The id of the figure to be used.

  • new_figure (bool, optional) – If True, a new figure is created.

  • render_image (bool, optional) – If True and the image exists, then it gets rendered.

  • render_final_shape (bool, optional) – If True, then the final fitting shape gets rendered.

  • render_initial_shape (bool, optional) – If True and the initial fitting shape exists, then it gets rendered.

  • render_gt_shape (bool, optional) – If True and the ground truth shape exists, then it gets rendered.

  • subplots_enabled (bool, optional) – If True, then the requested final, initial and ground truth shapes get rendered on separate subplots.

  • channels (int or list of int or all or None) – If int or list of int, the specified channel(s) will be rendered. If all, all the channels will be rendered in subplots. If None and the image is RGB, it will be rendered in RGB mode. If None and the image is not RGB, it is equivalent to all.

  • interpolation (See Below, optional) –

    The interpolation used to render the image. For example, if bilinear, the image will be smooth and if nearest, the image will be pixelated. Example options

    {none, nearest, bilinear, bicubic, spline16, spline36, hanning,
     hamming, hermite, kaiser, quadric, catrom, gaussian, bessel,
     mitchell, sinc, lanczos}
    

  • cmap_name (str, optional,) – If None, single channel and three channel images default to greyscale and rgb colormaps respectively.

  • alpha (float, optional) – The alpha blending value, between 0 (transparent) and 1 (opaque).

  • masked (bool, optional) – If True, then the image is rendered as masked.

  • final_marker_face_colour (See Below, optional) –

    The face (filling) colour of the markers of the final fitting shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • final_marker_edge_colour (See Below, optional) –

    The edge colour of the markers of the final fitting shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • final_line_colour (See Below, optional) –

    The line colour of the final fitting shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • initial_marker_face_colour (See Below, optional) –

    The face (filling) colour of the markers of the initial shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • initial_marker_edge_colour (See Below, optional) –

    The edge colour of the markers of the initial shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • initial_line_colour (See Below, optional) –

    The line colour of the initial shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • gt_marker_face_colour (See Below, optional) –

    The face (filling) colour of the markers of the ground truth shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • gt_marker_edge_colour (See Below, optional) –

    The edge colour of the markers of the ground truth shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • gt_line_colour (See Below, optional) –

    The line colour of the ground truth shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • render_lines (bool or list of bool, optional) – If True, the lines will be rendered. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order.

  • line_style (str or list of str, optional) –

    The style of the lines. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order. Example options:

    {'-', '--', '-.', ':'}
    

  • line_width (float or list of float, optional) – The width of the lines. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order.

  • render_markers (bool or list of bool, optional) – If True, the markers will be rendered. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order.

  • marker_style (str or list of str, optional) –

    The style of the markers. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order. Example options:

    {., ,, o, v, ^, <, >, +, x, D, d, s, p, *, h, H, 1, 2, 3, 4, 8}
    

  • marker_size (int or list of int, optional) – The size of the markers in points. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order.

  • marker_edge_width (float or list of float, optional) – The width of the markers’ edge. You can either provide a single value that will be used for all shapes or a list with a different value per shape in (final, initial, groundtruth) order.

  • render_numbering (bool, optional) – If True, the landmarks will be numbered.

  • numbers_horizontal_align ({center, right, left}, optional) – The horizontal alignment of the numbers’ texts.

  • numbers_vertical_align ({center, top, bottom, baseline}, optional) – The vertical alignment of the numbers’ texts.

  • numbers_font_name (See Below, optional) –

    The font of the numbers. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • numbers_font_size (int, optional) – The font size of the numbers.

  • numbers_font_style ({normal, italic, oblique}, optional) – The font style of the numbers.

  • numbers_font_weight (See Below, optional) –

    The font weight of the numbers. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • numbers_font_colour (See Below, optional) –

    The font colour of the numbers. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • render_legend (bool, optional) – If True, the legend will be rendered.

  • legend_title (str, optional) – The title of the legend.

  • legend_font_name (See below, optional) –

    The font of the legend. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • legend_font_style ({normal, italic, oblique}, optional) – The font style of the legend.

  • legend_font_size (int, optional) – The font size of the legend.

  • legend_font_weight (See Below, optional) –

    The font weight of the legend. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • legend_marker_scale (float, optional) – The relative size of the legend markers with respect to the original

  • legend_location (int, optional) –

    The location of the legend. The predefined values are:

    ’best’

    0

    ’upper right’

    1

    ’upper left’

    2

    ’lower left’

    3

    ’lower right’

    4

    ’right’

    5

    ’center left’

    6

    ’center right’

    7

    ’lower center’

    8

    ’upper center’

    9

    ’center’

    10

  • legend_bbox_to_anchor ((float, float) tuple, optional) – The bbox that the legend will be anchored.

  • legend_border_axes_pad (float, optional) – The pad between the axes and legend border.

  • legend_n_columns (int, optional) – The number of the legend’s columns.

  • legend_horizontal_spacing (float, optional) – The spacing between the columns.

  • legend_vertical_spacing (float, optional) – The vertical space between the legend entries.

  • legend_border (bool, optional) – If True, a frame will be drawn around the legend.

  • legend_border_padding (float, optional) – The fractional whitespace inside the legend border.

  • legend_shadow (bool, optional) – If True, a shadow will be drawn behind legend.

  • legend_rounded_corners (bool, optional) – If True, the frame’s corners will be rounded (fancybox).

  • render_axes (bool, optional) – If True, the axes will be rendered.

  • axes_font_name (See Below, optional) –

    The font of the axes. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • axes_font_size (int, optional) – The font size of the axes.

  • axes_font_style ({normal, italic, oblique}, optional) – The font style of the axes.

  • axes_font_weight (See Below, optional) –

    The font weight of the axes. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • axes_x_limits (float or (float, float) or None, optional) – The limits of the x axis. If float, then it sets padding on the right and left of the Image as a percentage of the Image’s width. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_y_limits ((float, float) tuple or None, optional) – The limits of the y axis. If float, then it sets padding on the top and bottom of the Image as a percentage of the Image’s height. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_x_ticks (list or tuple or None, optional) – The ticks of the x axis.

  • axes_y_ticks (list or tuple or None, optional) – The ticks of the y axis.

  • figure_size ((float, float) tuple or None optional) – The size of the figure in inches.

Returns

renderer (class) – The renderer object.

view_iterations(figure_id=None, new_figure=False, iters=None, render_image=True, subplots_enabled=False, channels=None, interpolation='bilinear', cmap_name=None, alpha=1.0, masked=True, render_lines=True, line_style='-', line_width=2, line_colour=None, render_markers=True, marker_edge_colour=None, marker_face_colour=None, marker_style='o', marker_size=4, marker_edge_width=1.0, render_numbering=False, numbers_horizontal_align='center', numbers_vertical_align='bottom', numbers_font_name='sans-serif', numbers_font_size=10, numbers_font_style='normal', numbers_font_weight='normal', numbers_font_colour='k', render_legend=True, legend_title='', legend_font_name='sans-serif', legend_font_style='normal', legend_font_size=10, legend_font_weight='normal', legend_marker_scale=None, legend_location=2, legend_bbox_to_anchor=(1.05, 1.0), legend_border_axes_pad=None, legend_n_columns=1, legend_horizontal_spacing=None, legend_vertical_spacing=None, legend_border=True, legend_border_padding=None, legend_shadow=False, legend_rounded_corners=False, render_axes=False, axes_font_name='sans-serif', axes_font_size=10, axes_font_style='normal', axes_font_weight='normal', axes_x_limits=None, axes_y_limits=None, axes_x_ticks=None, axes_y_ticks=None, figure_size=(7, 7))

Visualize the iterations of the fitting process.

Parameters
  • figure_id (object, optional) – The id of the figure to be used.

  • new_figure (bool, optional) – If True, a new figure is created.

  • iters (int or list of int or None, optional) –

    The iterations to be visualized. If None, then all the iterations are rendered.

    No.

    Visualised shape

    Description

    0

    self.initial_shape

    Initial shape

    1

    self.reconstructed_initial_shape

    Reconstructed initial

    2

    self.shapes[2]

    Iteration 1

    i

    self.shapes[i]

    Iteration i-1

    n_iters+1

    self.final_shape

    Final shape

  • render_image (bool, optional) – If True and the image exists, then it gets rendered.

  • subplots_enabled (bool, optional) – If True, then the requested final, initial and ground truth shapes get rendered on separate subplots.

  • channels (int or list of int or all or None) – If int or list of int, the specified channel(s) will be rendered. If all, all the channels will be rendered in subplots. If None and the image is RGB, it will be rendered in RGB mode. If None and the image is not RGB, it is equivalent to all.

  • interpolation (str (See Below), optional) –

    The interpolation used to render the image. For example, if bilinear, the image will be smooth and if nearest, the image will be pixelated. Example options

    {none, nearest, bilinear, bicubic, spline16, spline36, hanning,
     hamming, hermite, kaiser, quadric, catrom, gaussian, bessel,
     mitchell, sinc, lanczos}
    

  • cmap_name (str, optional,) – If None, single channel and three channel images default to greyscale and rgb colormaps respectively.

  • alpha (float, optional) – The alpha blending value, between 0 (transparent) and 1 (opaque).

  • masked (bool, optional) – If True, then the image is rendered as masked.

  • render_lines (bool or list of bool, optional) – If True, the lines will be rendered. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape.

  • line_style (str or list of str (See below), optional) –

    The style of the lines. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape. Example options:

    {-, --, -., :}
    

  • line_width (float or list of float, optional) – The width of the lines. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape.

  • line_colour (colour or list of colour (See Below), optional) –

    The colour of the lines. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • render_markers (bool or list of bool, optional) – If True, the markers will be rendered. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape.

  • marker_style (str or `list of str (See below), optional) –

    The style of the markers. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape. Example options

    {., ,, o, v, ^, <, >, +, x, D, d, s, p, *, h, H, 1, 2, 3, 4, 8}
    

  • marker_size (int or list of int, optional) – The size of the markers in points. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape.

  • marker_edge_colour (colour or list of colour (See Below), optional) –

    The edge colour of the markers. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • marker_face_colour (colour or list of colour (See Below), optional) –

    The face (filling) colour of the markers. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • marker_edge_width (float or list of float, optional) – The width of the markers’ edge. You can either provide a single value that will be used for all shapes or a list with a different value per iteration shape.

  • render_numbering (bool, optional) – If True, the landmarks will be numbered.

  • numbers_horizontal_align (str (See below), optional) –

    The horizontal alignment of the numbers’ texts. Example options

    {center, right, left}
    

  • numbers_vertical_align (str (See below), optional) –

    The vertical alignment of the numbers’ texts. Example options

    {center, top, bottom, baseline}
    

  • numbers_font_name (str (See below), optional) –

    The font of the numbers. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • numbers_font_size (int, optional) – The font size of the numbers.

  • numbers_font_style ({normal, italic, oblique}, optional) – The font style of the numbers.

  • numbers_font_weight (str (See below), optional) –

    The font weight of the numbers. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • numbers_font_colour (See Below, optional) –

    The font colour of the numbers. Example options

    {r, g, b, c, m, k, w}
    or
    (3, ) ndarray
    

  • render_legend (bool, optional) – If True, the legend will be rendered.

  • legend_title (str, optional) – The title of the legend.

  • legend_font_name (See below, optional) –

    The font of the legend. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • legend_font_style (str (See below), optional) –

    The font style of the legend. Example options

    {normal, italic, oblique}
    

  • legend_font_size (int, optional) – The font size of the legend.

  • legend_font_weight (str (See below), optional) –

    The font weight of the legend. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • legend_marker_scale (float, optional) – The relative size of the legend markers with respect to the original

  • legend_location (int, optional) –

    The location of the legend. The predefined values are:

    ’best’

    0

    ’upper right’

    1

    ’upper left’

    2

    ’lower left’

    3

    ’lower right’

    4

    ’right’

    5

    ’center left’

    6

    ’center right’

    7

    ’lower center’

    8

    ’upper center’

    9

    ’center’

    10

  • legend_bbox_to_anchor ((float, float) tuple, optional) – The bbox that the legend will be anchored.

  • legend_border_axes_pad (float, optional) – The pad between the axes and legend border.

  • legend_n_columns (int, optional) – The number of the legend’s columns.

  • legend_horizontal_spacing (float, optional) – The spacing between the columns.

  • legend_vertical_spacing (float, optional) – The vertical space between the legend entries.

  • legend_border (bool, optional) – If True, a frame will be drawn around the legend.

  • legend_border_padding (float, optional) – The fractional whitespace inside the legend border.

  • legend_shadow (bool, optional) – If True, a shadow will be drawn behind legend.

  • legend_rounded_corners (bool, optional) – If True, the frame’s corners will be rounded (fancybox).

  • render_axes (bool, optional) – If True, the axes will be rendered.

  • axes_font_name (str (See below), optional) –

    The font of the axes. Example options

    {serif, sans-serif, cursive, fantasy, monospace}
    

  • axes_font_size (int, optional) – The font size of the axes.

  • axes_font_style ({normal, italic, oblique}, optional) – The font style of the axes.

  • axes_font_weight (str (See below), optional) –

    The font weight of the axes. Example options

    {ultralight, light, normal, regular, book, medium, roman,
     semibold, demibold, demi, bold, heavy, extra bold, black}
    

  • axes_x_limits (float or (float, float) or None, optional) – The limits of the x axis. If float, then it sets padding on the right and left of the Image as a percentage of the Image’s width. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_y_limits ((float, float) tuple or None, optional) – The limits of the y axis. If float, then it sets padding on the top and bottom of the Image as a percentage of the Image’s height. If tuple or list, then it defines the axis limits. If None, then the limits are set automatically.

  • axes_x_ticks (list or tuple or None, optional) – The ticks of the x axis.

  • axes_y_ticks (list or tuple or None, optional) – The ticks of the y axis.

  • figure_size ((float, float) tuple or None optional) – The size of the figure in inches.

Returns

renderer (class) – The renderer object.

view_widget(figure_size=(7, 7))

Visualizes the result object using an interactive widget.

Parameters

figure_size ((int, int), optional) – The initial size of the rendered figure.

property appearance_parameters

Returns the list of appearance parameters obtained at each iteration of the fitting process. The list includes the parameters of the initial_shape (if it exists) and final_shape.

Type

list of (n_params,) ndarray

property costs

Returns a list with the cost per iteration. It returns None if the costs are not computed.

Type

list of float or None

property final_shape

Returns the final shape of the fitting process.

Type

menpo.shape.PointCloud

property gt_shape

Returns the ground truth shape associated with the image. In case there is not an attached ground truth shape, then None is returned.

Type

menpo.shape.PointCloud or None

property image

Returns the image that the fitting was applied on, if it was provided. Otherwise, it returns None.

Type

menpo.shape.Image or subclass or None

property initial_shape

Returns the initial shape that was provided to the fitting method to initialise the fitting process. In case the initial shape does not exist, then None is returned.

Type

menpo.shape.PointCloud or None

property is_iterative

Flag whether the object is an iterative fitting result.

Type

bool

property n_iters

Returns the total number of iterations of the fitting process.

Type

int

property reconstructed_initial_shape

Returns the initial shape’s reconstruction with the shape model that was used to initialise the iterative optimisation process.

Type

menpo.shape.PointCloud

property shape_parameters

Returns the list of shape parameters obtained at each iteration of the fitting process. The list includes the parameters of the reconstructed_initial_shape and final_shape.

Type

list of (n_params,) ndarray

property shapes

Returns the list of shapes obtained at each iteration of the fitting process. The list includes the initial_shape (if it exists), reconstructed_initial_shape and final_shape.

Type

list of menpo.shape.PointCloud