Utils
plot_image¶
Plots image using matplotlib.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
ndarray
|
The frame to be displayed. |
required |
size |
Tuple[int, int]
|
The size of the plot. |
(12, 12)
|
cmap |
str
|
the colormap to use for single channel images. |
'gray'
|
Examples:
>>> import cv2
>>> import supervision as sv
>>> image = cv2.imread("path/to/image.jpg")
%matplotlib inline
>>> sv.plot_image(image=image, size=(16, 16))
Source code in supervision/notebook/utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
plot_images_grid¶
Plots images in a grid using matplotlib.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images |
List[ndarray]
|
A list of images as numpy arrays. |
required |
grid_size |
Tuple[int, int]
|
A tuple specifying the number of rows and columns for the grid. |
required |
titles |
Optional[List[str]]
|
A list of titles for each image. Defaults to None. |
None
|
size |
Tuple[int, int]
|
A tuple specifying the width and height of the entire plot in inches. |
(12, 12)
|
cmap |
str
|
the colormap to use for single channel images. |
'gray'
|
Raises:
Type | Description |
---|---|
ValueError
|
If the number of images exceeds the grid size. |
Examples:
>>> import cv2
>>> import supervision as sv
>>> image1 = cv2.imread("path/to/image1.jpg")
>>> image2 = cv2.imread("path/to/image2.jpg")
>>> image3 = cv2.imread("path/to/image3.jpg")
>>> images = [image1, image2, image3]
>>> titles = ["Image 1", "Image 2", "Image 3"]
%matplotlib inline
>>> plot_images_grid(images, grid_size=(2, 2), titles=titles, size=(16, 16))
Source code in supervision/notebook/utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|