bob.med.tb.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

ElasticDeformation([alpha, sigma, …])

Elastic deformation of 2D image slightly adapted from [SIMARD-2003].

RemoveBlackBorders([threshold])

Remove black borders of CXR

SingleAutoLevel16to8()

Converts a 16-bit image to 8-bit representation using “auto-level”

class bob.med.tb.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.med.tb.data.transforms.RemoveBlackBorders(threshold=0)[source]

Bases: object

Remove black borders of CXR

class bob.med.tb.data.transforms.ElasticDeformation(alpha=1000, sigma=30, spline_order=1, mode='nearest', random_state=<module 'numpy.random' from '/scratch/builds/bob/bob.med.tb/miniconda/conda-bld/bob.med.tb_1626259895372/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.8/site-packages/numpy/random/__init__.py'>, p=1)[source]

Bases: object

Elastic deformation of 2D image slightly adapted from [SIMARD-2003]. .. [SIMARD-2003] Simard, Steinkraus and Platt, “Best Practices for Convolutional Neural Networks applied to Visual Document Analysis”, in Proc. of the International Conference on Document Analysis and Recognition, 2003. Source: https://gist.github.com/oeway/2e3b989e0343f0884388ed7ed82eb3b0