Result¶
-
class
menpofit.result.
Result
(final_shape, image=None, initial_shape=None, gt_shape=None)[source]¶ Bases:
object
Class for defining a basic fitting result. It holds the final shape of a fitting process and, optionally, the initial shape, ground truth shape and the image object.
Parameters: - final_shape (menpo.shape.PointCloud) – The final shape of the fitting process.
- 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. IfNone
, then no image is assigned. - initial_shape (menpo.shape.PointCloud or
None
, optional) – The initial shape that was provided to the fitting method to initialise the fitting process. IfNone
, then no initial shape is assigned. - gt_shape (menpo.shape.PointCloud or
None
, optional) – The ground truth shape associated with the image. IfNone
, then no ground truth shape is assigned.
-
final_error
(compute_error=None)[source]¶ 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)[source]¶ 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 computedValueError
– Ground truth shape has not been set, so the initial error cannot be computed
-
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=(10, 8))[source]¶ 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
orNone
) – If int or list of int, the specified channel(s) will be rendered. Ifall
, all the channels will be rendered in subplots. IfNone
and the image is RGB, it will be rendered in RGB mode. IfNone
and the image is not RGB, it is equivalent toall
. - interpolation (See Below, optional) –
The interpolation used to render the image. For example, if
bilinear
, the image will be smooth and ifnearest
, 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. IfNone
, 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. IfNone
, 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
(browser_style='buttons', figure_size=(10, 8), style='coloured')[source]¶ Visualizes the result object using an interactive widget.
Parameters: - browser_style ({
'buttons'
,'slider'
}, optional) – It defines whether the selector of the images will have the form of plus/minus buttons or a slider. - figure_size ((int, int), optional) – The initial size of the rendered figure.
- style ({
'coloured'
,'minimal'
}, optional) – If'coloured'
, then the style of the widget will be coloured. Ifminimal
, then the style is simple using black and white colours.
- browser_style ({
-
final_shape
¶ Returns the final shape of the fitting process.
Type: menpo.shape.PointCloud
-
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
-
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
-
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
-
is_iterative
¶ Flag whether the object is an iterative fitting result.
Type: bool