view_patches¶
-
menpo.visualize.
view_patches
(patches, patch_centers, patches_indices=None, offset_index=None, figure_id=None, new_figure=False, background='white', render_patches=True, channels=None, interpolation='none', cmap_name=None, alpha=1.0, render_patches_bboxes=True, bboxes_line_colour='r', bboxes_line_style='-', bboxes_line_width=1, render_centers=True, render_lines=True, line_colour=None, line_style='-', line_width=1, render_markers=True, marker_style='o', marker_size=5, marker_face_colour=None, marker_edge_colour=None, 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_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))[source]¶ Method that renders the provided patches on a canvas. The user can choose whether to render the patch centers (render_centers) as well as rectangle boundaries around the patches (render_patches_bboxes).
The patches argument can have any of the two formats that are returned from the extract_patches() and extract_patches_around_landmarks() methods of the
Image
class. Specifically it can be:(n_center, n_offset, self.n_channels, patch_shape)
ndarraylist of
n_center * n_offset
Image
objects
- Parameters
patches (ndarray or list) – The values of the patches. It can have any of the two formats that are returned from the extract_patches() and extract_patches_around_landmarks() methods. Specifically, it can either be an
(n_center, n_offset, self.n_channels, patch_shape)
ndarray or a list ofn_center * n_offset
Image
objects.patch_centers (
PointCloud
) – The centers around which to visualize the patches.patches_indices (int or list of int or
None
, optional) – Defines the patches that will be visualized. IfNone
, then all the patches are selected.offset_index (int or
None
, optional) – The offset index within the provided patches argument, thus the index of the second dimension from which to sample. IfNone
, then0
is used.figure_id (object, optional) – The id of the figure to be used.
new_figure (bool, optional) – If
True
, a new figure is created.background (
{'black', 'white'}
, optional) – If'black'
, then the background is set equal to the minimum value of patches. If'white'
, then the background is set equal to the maximum value of patches.render_patches (bool, optional) – Flag that determines whether to render the patch values.
channels (int or list of int or
all
orNone
, optional) – 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).
render_patches_bboxes (bool, optional) – Flag that determines whether to render the bounding box lines around the patches.
bboxes_line_colour (See Below, optional) –
The colour of the lines. Example options:
{r, g, b, c, m, k, w} or (3, ) ndarray
bboxes_line_style (
{-, --, -., :}
, optional) – The style of the lines.bboxes_line_width (float, optional) – The width of the lines.
render_centers (bool, optional) – Flag that determines whether to render the patch centers.
render_lines (bool, optional) – If
True
, the edges will be rendered.line_colour (See Below, optional) –
The colour of the lines. Example options:
{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 (See Below, optional) –
The style of the markers. Example 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 (See Below, optional) –
The face (filling) colour of the markers. Example options
{r, g, b, c, m, k, w} or (3, ) ndarray
marker_edge_colour (See Below, optional) –
The edge colour of the markers. Example options
{r, g, b, c, m, k, w} or (3, ) ndarray
marker_edge_width (float, optional) – The width of the markers’ edge.
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_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 shape as a percentage of the shape’s width. If tuple or list, then it defines the axis limits. IfNone
, 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 shape as a percentage of the shape’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
viewer (ImageViewer) – The image viewing object.