Module delta.extensions.preprocess

Various helpful preprocessing functions.

These are intended to be included in image: preprocess in a yaml file. See the delta.config documentation for details. Note that for all functions, the image_type will be specified automatically: other parameters must be specified in the config file.

Functions

def cbrt(image_type)

Cubic root.

def clip(image_type, bounds)

Clips all pixel values within a range.

Parameters

bounds : List[float]
List of two floats to clip all values between.
def gauss_mult_noise(image_type, stddev)

Multiplies each pixel by p ~ Normal(1, stddev)

Parameters

stddev : float
Standard deviation of distribution to sample from.
def offset(image_type, factor)

Add an amount to all pixels.

Parameters

factor : float
Number to add.
def scale(image_type, factor='default')

Divides by a given scale factor.

Parameters

factor : Union[str, float]
Scale factor to divide by. 'default' will scale by an image type specific default amount.
def sqrt(image_type)

Square root.

def substitute(image_type, mapping)

Replaces pixels in image with the listed values.

Parameters

mapping : List[Any]
For example, to change a binary image to a one-hot representation, use [[1, 0], [0, 1]]. This replaces all 0 pixels with [1, 0] and all 1 pixels with [0, 1].