Source code for vis4d.vis.image.viewer.matplotlib_viewer
"""Matplotlib based image viewer."""from__future__importannotationsimportmatplotlib.pyplotaspltfromvis4d.common.typingimportNDArrayUI8from.baseimportImageViewerBackend
[docs]classMatplotlibImageViewer(ImageViewerBackend):"""A image viewer using matplotlib.pyplot."""
[docs]defshow_images(self,images:list[NDArrayUI8],blocking:bool=True)->None:"""Shows a list of images. Args: images (list[NDArrayUI8]): Images to display. blocking (bool): If the viewer should be blocking and wait for human input after each image. """forimageinimages:plt.imshow(image)plt.axis("off")plt.show(block=blocking)
[docs]defsave_images(self,images:list[NDArrayUI8],file_paths:list[str])->None:"""Saves a list of images. Args: images (list[NDArrayUI8]): Images to save. file_paths (list[str]): File paths to save the images to. """fori,imageinenumerate(images):plt.imshow(image)plt.axis("off")plt.savefig(f"{file_paths[i]}",bbox_inches="tight")