anomalib.data.utils.image

Image Utils.

Module Contents

Functions

get_image_filenames(path: Union[str, pathlib.Path]) → List[str]

Get image filenames.

read_image(path: Union[str, pathlib.Path]) → numpy.ndarray

Read image from disk in RGB format.

pad_nextpow2(batch: torch.Tensor) → torch.Tensor

Compute required padding from input size and return padded images.

anomalib.data.utils.image.get_image_filenames(path: Union[str, pathlib.Path]) List[str][source]

Get image filenames.

Parameters

path (Union[str, Path]) – Path to image or image-folder.

Returns

List of image filenames

Return type

List[str]

anomalib.data.utils.image.read_image(path: Union[str, pathlib.Path]) numpy.ndarray[source]

Read image from disk in RGB format.

Parameters

path (str, Path) – path to the image file

Example

>>> image = read_image("test_image.jpg")
Returns

image as numpy array

anomalib.data.utils.image.pad_nextpow2(batch: torch.Tensor) torch.Tensor[source]

Compute required padding from input size and return padded images.

Finds the largest dimension and computes a square image of dimensions that are of the power of 2. In case the image dimension is odd, it returns the image with an extra padding on one side.

Parameters

batch (Tensor) – Input images

Returns

Padded batch

Return type

batch