bob.ip.common.data.transforms¶
Image transformations for our pipelines
Differences between methods here and those from
torchvision.transforms
is that these support multiple simultaneous
image inputs, which are required to feed segmentation networks (e.g. image and
labels or masks). We also take care of data augmentations, in which random
flipping and rotation needs to be applied across all input images, but color
jittering, for example, only on the input image.
Classes
Converts multiple 16-bit images to 8-bit representations using "auto-level" |
|
|
|
|
Randomly applies a color jitter transformation on the first image |
|
|
|
Crops multiple images at the given coordinates. |
|
Randomly applies a gaussian blur transformation on the first image |
|
Returns image tensor and its corresponding target dict given a mask. |
|
|
|
Randomly flips all input images horizontally |
|
Randomly rotates all input images by the same amount |
|
Randomly flips all input images vertically |
|
|
|
Crops black borders and then resize to a square with minimal padding |
Converts a 16-bit image to 8-bit representation using "auto-level" |
|
|
Crops one image at the given coordinates. |
Converts from any input format to RGB, using an ADAPTIVE conversion. |
|
|
Converts from any input format to RGB, using an ADAPTIVE conversion. |
|
|
Adds support to work with tuples of objects to torchvision transforms |
- class bob.ip.common.data.transforms.TupleMixin[source]¶
Bases:
object
Adds support to work with tuples of objects to torchvision transforms
- class bob.ip.common.data.transforms.CenterCrop(size)[source]¶
Bases:
TupleMixin
,CenterCrop
- class bob.ip.common.data.transforms.Pad(padding, fill=0, padding_mode='constant')[source]¶
Bases:
TupleMixin
,Pad
- class bob.ip.common.data.transforms.Resize(size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=None)[source]¶
Bases:
TupleMixin
,Resize
- class bob.ip.common.data.transforms.ToTensor[source]¶
Bases:
TupleMixin
,ToTensor
- class bob.ip.common.data.transforms.SingleCrop(i, j, h, w)[source]¶
Bases:
object
Crops one image at the given coordinates.
- class bob.ip.common.data.transforms.Crop(i, j, h, w)[source]¶
Bases:
TupleMixin
,SingleCrop
Crops multiple images at the given coordinates.
- class bob.ip.common.data.transforms.SingleAutoLevel16to8[source]¶
Bases:
object
Converts a 16-bit image to 8-bit representation using “auto-level”
This transform assumes that the input image is gray-scaled.
To auto-level, we calculate the maximum and the minimum of the image, and consider such a range should be mapped to the [0,255] range of the destination image.
- class bob.ip.common.data.transforms.AutoLevel16to8[source]¶
Bases:
TupleMixin
,SingleAutoLevel16to8
Converts multiple 16-bit images to 8-bit representations using “auto-level”
This transform assumes that the input images are gray-scaled.
To auto-level, we calculate the maximum and the minimum of the image, and consider such a range should be mapped to the [0,255] range of the destination image.
- class bob.ip.common.data.transforms.SingleToRGB[source]¶
Bases:
object
Converts from any input format to RGB, using an ADAPTIVE conversion.
This transform takes the input image and converts it to RGB using py:method:PIL.Image.Image.convert, with mode=’RGB’ and using all other defaults. This may be aggressive if applied to 16-bit images without further considerations.
- class bob.ip.common.data.transforms.ToRGB[source]¶
Bases:
TupleMixin
,SingleToRGB
Converts from any input format to RGB, using an ADAPTIVE conversion.
This transform takes the input image and converts it to RGB using py:method:PIL.Image.Image.convert, with mode=’RGB’ and using all other defaults. This may be aggressive if applied to 16-bit images without further considerations.
- class bob.ip.common.data.transforms.RandomHorizontalFlip(p=0.5)[source]¶
Bases:
RandomHorizontalFlip
Randomly flips all input images horizontally
- class bob.ip.common.data.transforms.RandomVerticalFlip(p=0.5)[source]¶
Bases:
RandomVerticalFlip
Randomly flips all input images vertically
- class bob.ip.common.data.transforms.RandomRotation(p=0.5, **kwargs)[source]¶
Bases:
RandomRotation
Randomly rotates all input images by the same amount
Unlike the current torchvision implementation, we also accept a probability for applying the rotation.
- Parameters
- class bob.ip.common.data.transforms.ColorJitter(p=0.5, **kwargs)[source]¶
Bases:
ColorJitter
Randomly applies a color jitter transformation on the first image
Notice this transform extension, unlike others in this module, only affects the first image passed as input argument. Unlike the current torchvision implementation, we also accept a probability for applying the jitter.
- class bob.ip.common.data.transforms.ShrinkIntoSquare(reference=0, threshold=0)[source]¶
Bases:
object
Crops black borders and then resize to a square with minimal padding
This transform can crop all the images by removing the black pixels in the width and height until it finds a non-black pixel. Then, expands the image back until it makes a square with minimal size.
- class bob.ip.common.data.transforms.GaussianBlur(p=0.5, **kwargs)[source]¶
Bases:
GaussianBlur
Randomly applies a gaussian blur transformation on the first image
Notice this transform extension, unlike others in this module, only affects the first image passed as input argument. Unlike the current torchvision implementation, we also accept a probability for applying the blur.