Notebooks Utils¶
Plots image using matplotlib.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
ImageType
|
The frame to be displayed ImageType
is a flexible type, accepting either |
required |
size |
Tuple[int, int]
|
The size of the plot in inches. |
(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/utils/notebook.py
Plots images in a grid using matplotlib.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images |
List[ImageType]
|
A list of images as ImageType
is a flexible type, accepting either |
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
from PIL import Image
image1 = cv2.imread("path/to/image1.jpg")
image2 = Image.open("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))