dgs.utils.image¶
Utility for handling images in pytorch.
Loading, saving, manipulating of RGB-images.
Within pytorch an image is a Byte-, Uint8-, or Float-Tensor with a shape of [C x h x w]
.
Within torchvision an image is a tv_tensor.Image object with the same shape.
A Batch of torch images therefore has a shape of [B x C x h x w]
.
Within pytorch and torchvision, the images have channels in order of RGB.
The size / shape of an image is given as tuple (and sometimes list) of ints in the form of (h, w).
RGB Images in cv2 have a shape of [h x w x C]
and the channels are in order GBR.
Grayscale Images in cv2 have a shape of [h x w]
.
Module Functions
|
Combine multiple images into a single video. |
|
Given the width and height of an old and image, compute the size of a padding around the old image such that the aspect ratio matches a target. |
|
Given the x- and y- coordinates of one or multiple polygons, create a |
|
Load an image or multiple images given a single or multiple filepaths. |
|
Load multiple images with possibly different sizes as a list of tv_tensor images. |
|
Load a video from a given filepath. |
Module Classes
|
Extract all bounding boxes of a single torch tensor image as new image crops then resize the result to the given output shape, which makes the results stackable again. |
|
Resize image, bbox and key points with this custom transform. |
|
Custom torchvision Transform that modifies the image, bboxes, and coordinates simultaneously to match a target aspect ratio. |
All the custom transforms need to extract and validate values from args and kwargs. |