Shapes¶
Shapes¶
- deepbench.shapes.Shapes¶
alias of
ShapeGenerator
- class deepbench.shapes.shape_generator.ShapeGenerator(image_shape=(28, 28))¶
- Parameters:
image_shape (tuple)
- create_arc(center=(14, 10), radius=9.883982090390571, theta1=18.086046445701104, theta2=119.98833673702778, line_width=1)¶
Create an arc with radius “radius” arcing from theta1 to theta2 counter-clockwise
- Parameters:
center (tuple, optional) – Center point of the arc. Defaults to (np.random.randint(10, 16), np.random.randint(10, 16)).
radius (Union[int, float], optional) – distance from the arc to the center point. Defaults to np.random.random(8, 12).
theta1 (Union[int, float], optional) – starting point of the arc (degrees). Defaults to np.random.random(0, 45).
theta2 (Union[int, float], optional) – ending point of the arc (degrees). Defaults to np.random.random(85, 120).
line_width (int, optional) – thickness of the arc (pixels) Defaults to 1.
- Returns:
The arc image
- Return type:
np.ndarray
- create_ellipse(center=(14, 11), width=10, height=14, angle=0, line_width=1, fill=False)¶
Create an ellipse/circle (where width/height are the same)
- Parameters:
center (tuple, optional) – Center point of the ellipse. Defaults to (np.random.randint(10, 16), np.random.randint(10, 16)).
width (int, optional) – Horizontal length of the ellipse (pixels). Defaults to np.random.randint(10, 16).
height (int, optional) – Vertical height of the ellipse (pixels). Defaults to np.random.randint(10, 16).
angle (Union[float, int], optional) – Rotation angle of the ellipse (degrees). Defaults to 0.
line_width (int, optional) – Width of the ellipse’s border (pixels). Defaults to 1.
fill (bool, optional) – Fill the center of the ellipse. Defaults to False.
- Returns:
np.ndarray
- create_empty_shape()¶
Create an array of 0s with shape self.image_shape
- Returns:
np.ndarray
- create_line(start=(7, 5), end=(26, 15), line_width=1)¶
Generate a numpy array of a line
- Parameters:
start (tuple, optional) – Starting corner of the line. Defaults to (np.random.randint(0, 10), np.random.randint(0, 10)).
end (tuple, optional) – Ending corner of the line. Defaults to (np.random.randint(12, 28), np.random.randint(12, 28)).
line_width (int, optional) – Thickness of the line (pixels). Defaults to 1.
- Returns:
np.ndarray
- create_rectangle(center=(14, 11), width=11, height=12, angle=0, line_width=1, fill=False)¶
Make a rectangle.
- Parameters:
center (tuple(*int), optional) – Center of the rectangle (coordinate). Defaults to (14, 14).
width (int, optional) – Horizontal width of the rectangle (in pixels). Defaults to random int.
height (int, optional) – Vertical height of the rectangle (in pixels). Defaults to random int.
angle (Union[float, int], optional) – tilt the rectangle (degrees). Defaults to 0.
line_width (int, optional) – line width of the outline. Defaults to 1.
fill (bool, optional) – Fill in the rectangle. Defaults to False.
- Returns:
A Rectangle image
- Return type:
np.ndarray
- create_regular_polygon(center=(11, 15), angle=62.82645225403612, vertices=3, radius=11.148967479691446, line_width=1, fill=False)¶
Create a polygon with equal length sides
- Parameters:
center (tuple[*int], optional) – Where to center the object.
angle (Union[int, float], optional) – Angle of rotation (degrees)
vertices (int, optional) – Number of verticies. Defaults to 3, a triangle.
radius (int, optional) – distance from vertex to vertex Defaults to 10.
line_width (int, optional) – line width of the outline. Defaults to 1.
fill (bool, optional) – Fill in the rectangle. Defaults to False.
- Returns:
A polygon image
- Return type:
np.ndarray
- resize(image, resize_dimensions=(28, 28))¶
Resize an array-like
- Parameters:
image (np.ndarray) – shape to resize
resize_dimensions (tuple, optional) – resize to shape. Defaults to (28, 28).
- Raises:
ValueError – invalid size, either too small (0,0) or having the number of incorrect dimensions
- Returns:
array of size (resize_dimensions)
- Return type:
np.ndarray