bob.ip.binseg.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 flips all input images horizontally |
|
Randomly rotates all input images by the same amount |
|
Randomly flips all input images vertically |
|
|
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.binseg.data.transforms.
TupleMixin
[source]¶ Bases:
object
Adds support to work with tuples of objects to torchvision transforms
-
class
bob.ip.binseg.data.transforms.
CenterCrop
(size)[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,torchvision.transforms.transforms.CenterCrop
-
class
bob.ip.binseg.data.transforms.
Pad
(padding, fill=0, padding_mode='constant')[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,torchvision.transforms.transforms.Pad
-
class
bob.ip.binseg.data.transforms.
Resize
(size, interpolation=2)[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,torchvision.transforms.transforms.Resize
-
class
bob.ip.binseg.data.transforms.
ToTensor
[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,torchvision.transforms.transforms.ToTensor
-
class
bob.ip.binseg.data.transforms.
SingleCrop
(i, j, h, w)[source]¶ Bases:
object
Crops one image at the given coordinates.
-
class
bob.ip.binseg.data.transforms.
Crop
(i, j, h, w)[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,bob.ip.binseg.data.transforms.SingleCrop
Crops multiple images at the given coordinates.
-
class
bob.ip.binseg.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.binseg.data.transforms.
AutoLevel16to8
[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,bob.ip.binseg.data.transforms.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.binseg.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.binseg.data.transforms.
ToRGB
[source]¶ Bases:
bob.ip.binseg.data.transforms.TupleMixin
,bob.ip.binseg.data.transforms.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.binseg.data.transforms.
RandomHorizontalFlip
(p=0.5)[source]¶ Bases:
torchvision.transforms.transforms.RandomHorizontalFlip
Randomly flips all input images horizontally
-
class
bob.ip.binseg.data.transforms.
RandomVerticalFlip
(p=0.5)[source]¶ Bases:
torchvision.transforms.transforms.RandomVerticalFlip
Randomly flips all input images vertically
-
class
bob.ip.binseg.data.transforms.
RandomRotation
(p=0.5, **kwargs)[source]¶ Bases:
torchvision.transforms.transforms.RandomRotation
Randomly rotates all input images by the same amount
Unlike the current torchvision implementation, we also accept a probability for applying the rotation.
-
class
bob.ip.binseg.data.transforms.
ColorJitter
(p=0.5, **kwargs)[source]¶ Bases:
torchvision.transforms.transforms.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.