pysdic.ImagePlotter#
The pysdic.ImagePlotter draws images, the sensor of a camera and the geometrical objects of pysdic (pysdic.PointCloud, pysdic.Mesh, pysdic.IntegrationPoints) in the image coordinate system with matplotlib. Its API mirrors the one of pysdic.Plotter3D.
The objects are projected with the camera when their dimension is the input dimension of the camera (projected=None), or drawn directly as image points \((x, y)\) when they are 2D (see the projected argument).
ImagePlotter class#
- class ImagePlotter(source, *, figsize=None, ax=None)[source]#
Bases:
objectA plotter for the geometrical objects of pysdic (
pysdic.PointCloud,pysdic.Meshandpysdic.IntegrationPoints) and the images on the sensor of a camera, based onmatplotlib.The API mirrors
pysdic.Plotter3D:add_image,add_sensor,add_point_cloud,add_mesh,add_integration_points,add_rectangle,set_titleandshow. It also draws the regions of interest of the images withadd_roi.The plot is in the image coordinate system \((x, y)\) in pixels: \(x\) is the column index and \(y\) the row index (pointing downwards). The centers of the pixels are at integer coordinates, so the sensor covers \([-0.5, W - 0.5] \times [-0.5, H - 0.5]\).
The objects are drawn as follows, according to their dimension \(E\):
With
projected=None(default): if a camera is set and \(E\) is the input dimension of the camera, the points are projected withpysdic.Camera.project(). Otherwise \(E\) must be 2 and the points are drawn as image points \((x, y)\).With
projected=True: the points are always projected (a camera is required).With
projected=False: the points are always drawn as image points (\(E = 2\)).
The non-finite points (e.g. after a projection) are not drawn, nor the faces with a non-finite vertex.
- Parameters:
source (Union[
pysdic.Camera,pysdic.View, Tuple[Integral, Integral]]) – The camera (used to project the objects), the view (its camera and its image, the default ofadd_image()) or the sensor size(height, width)in pixels (only image points can then be drawn). The sensor size cannot be changed.figsize (Optional[Tuple[Real, Real]], optional) – The size of the new figure in inches (width, height). Default:
(8, 6). Cannot be given withax.ax (Optional[matplotlib.axes.Axes], optional) – Existing matplotlib axes to draw in (e.g. a subplot of a figure composed of several plotters). By default, a new figure is created.
- Raises:
TypeError – If
sourceoraxhas a wrong type.ValueError – If the sensor size or
figsizeare not strictly positive, or if bothfigsizeandaxare given.
Instantiation#
The ImagePlotter class is instantiated with a source and optional figure settings:
From a camera:
ImagePlotter(camera), to project the objects.From a view:
ImagePlotter(view), to project the objects and draw the image of the view by default.From a sensor size:
ImagePlotter((height, width)), to draw only image points.
The ax argument draws in existing matplotlib axes (e.g. a subplot of a larger figure).
Implemented methods and attributes#
The following sections provide an overview of the attributes and methods defined
in the pysdic.ImagePlotter class.
Attributes#
[Get] the internal matplotlib Axes object used for plotting. |
|
[Get] the camera used to project the objects, or None. |
|
[Get] the internal matplotlib Figure object used for plotting. |
|
[Get] the height of the sensor in pixels. |
|
[Get] the width of the sensor in pixels. |
Sensor and image#
|
Draw the sensor of the camera and optionally the grid of the pixels. |
|
Draw an image on the sensor, with its pixels centered at integer coordinates. |
Geometrical objects#
|
Add a point cloud to the plotter (projected or drawn as image points, see |
|
Add a mesh to the plotter (projected or drawn in image points, see |
|
Add integration points to the plotter, at their global coordinates in a mesh (see |
|
Draw a rectangle in the image plane (e.g. a subset of DIC). |
Figure methods#
|
Add a title to the plotter. |
Remove all the objects, color bars and the title from the plotter. |
|
Show the figure of the plotter (with |
|
Close the figure of the plotter to free its memory (the whole figure, also when the plotter draws in given axes). |