Skip to content

Functional transforms (augmentations.functional)

def albumentations.augmentations.functional.add_fog (img, fog_coef, alpha_coef, haze_list) [view source on GitHub]

Add fog to the image.

From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

Parameters:

Name Type Description
img numpy.ndarray

Image.

fog_coef float

Fog coefficient.

alpha_coef float

Alpha coefficient.

haze_list list

Returns:

Type Description
numpy.ndarray

Image.

def albumentations.augmentations.functional.add_rain (img, slant, drop_length, drop_width, drop_color, blur_value, brightness_coefficient, rain_drops) [view source on GitHub]

From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

Parameters:

Name Type Description
img numpy.ndarray

Image.

slant int
drop_length
drop_width
drop_color
blur_value int

Rainy view are blurry.

brightness_coefficient float

Rainy days are usually shady.

rain_drops

Returns:

Type Description
numpy.ndarray

Image.

def albumentations.augmentations.functional.add_shadow (img, vertices_list) [view source on GitHub]

Add shadows to the image.

From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

Parameters:

Name Type Description
img numpy.ndarray
vertices_list list

Returns:

Type Description
numpy.ndarray

def albumentations.augmentations.functional.add_snow (img, snow_point, brightness_coeff) [view source on GitHub]

Bleaches out pixels, imitation snow.

From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

Parameters:

Name Type Description
img numpy.ndarray

Image.

snow_point

Number of show points.

brightness_coeff

Brightness coefficient.

Returns:

Type Description
numpy.ndarray

Image.

def albumentations.augmentations.functional.add_sun_flare (img, flare_center_x, flare_center_y, src_radius, src_color, circles) [view source on GitHub]

Add sun flare.

From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

Parameters:

Name Type Description
img numpy.ndarray
flare_center_x float
flare_center_y float
src_radius
src_color int, int, int
circles list

Returns:

Type Description
numpy.ndarray

def albumentations.augmentations.functional.bbox_from_mask (mask) [view source on GitHub]

Create bounding box from binary mask (fast version)

Parameters:

Name Type Description
mask numpy.ndarray

binary mask.

Returns:

Type Description
tuple

A bounding box tuple (x_min, y_min, x_max, y_max).

def albumentations.augmentations.functional.equalize (img, mask=None, mode='cv', by_channels=True) [view source on GitHub]

Equalize the image histogram.

Parameters:

Name Type Description
img numpy.ndarray

RGB or grayscale image.

mask numpy.ndarray

An optional mask. If given, only the pixels selected by the mask are included in the analysis. Maybe 1 channel or 3 channel array.

mode str

{'cv', 'pil'}. Use OpenCV or Pillow equalization method.

by_channels bool

If True, use equalization by channels separately, else convert image to YCbCr representation and use equalization by Y channel.

Returns:

Type Description
numpy.ndarray

Equalized image.

def albumentations.augmentations.functional.fancy_pca (img, alpha=0.1) [view source on GitHub]

Perform 'Fancy PCA' augmentation from: http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf

Parameters:

Name Type Description
img numpy.ndarray

numpy array with (h, w, rgb) shape, as ints between 0-255

alpha float

how much to perturb/scale the eigen vecs and vals the paper used std=0.1

Returns:

Type Description
numpy.ndarray

numpy image-like array as uint8 range(0, 255)

def albumentations.augmentations.functional.iso_noise (image, color_shift=0.05, intensity=0.5, random_state=None, ** kwargs) [view source on GitHub]

Apply poisson noise to image to simulate camera sensor noise.

Parameters:

Name Type Description
image numpy.ndarray

Input image, currently, only RGB, uint8 images are supported.

color_shift float
intensity float

Multiplication factor for noise values. Values of ~0.5 are produce noticeable, yet acceptable level of noise.

random_state
**kwargs

Returns:

Type Description
numpy.ndarray

Noised image

def albumentations.augmentations.functional.mask_from_bbox (img, bbox) [view source on GitHub]

Create binary mask from bounding box

Parameters:

Name Type Description
img numpy.ndarray

input image

bbox

A bounding box tuple (x_min, y_min, x_max, y_max)

Returns:

Type Description
mask (numpy.ndarray)

binary mask

def albumentations.augmentations.functional.move_tone_curve (img, low_y, high_y) [view source on GitHub]

Rescales the relationship between bright and dark areas of the image by manipulating its tone curve.

Parameters:

Name Type Description
img numpy.ndarray

RGB or grayscale image.

low_y float

y-position of a Bezier control point used to adjust the tone curve, must be in range [0, 1]

high_y float

y-position of a Bezier control point used to adjust image tone curve, must be in range [0, 1]

def albumentations.augmentations.functional.multiply (img, multiplier) [view source on GitHub]

Parameters:

Name Type Description
img numpy.ndarray

Image.

multiplier numpy.ndarray

Multiplier coefficient.

Returns:

Type Description
numpy.ndarray

Image multiplied by multiplier coefficient.

def albumentations.augmentations.functional.posterize (img, bits) [view source on GitHub]

Reduce the number of bits for each color channel.

Parameters:

Name Type Description
img numpy.ndarray

image to posterize.

bits int

number of high bits. Must be in range [0, 8]

Returns:

Type Description
numpy.ndarray

Image with reduced color channels.

def albumentations.augmentations.functional.solarize (img, threshold=128) [view source on GitHub]

Invert all pixel values above a threshold.

Parameters:

Name Type Description
img numpy.ndarray

The image to solarize.

threshold int

All pixels above this greyscale level are inverted.

Returns:

Type Description
numpy.ndarray

Solarized image.

def albumentations.augmentations.functional.swap_tiles_on_image (image, tiles) [view source on GitHub]

Swap tiles on image.

Parameters:

Name Type Description
image np.ndarray

Input image.

tiles np.ndarray

array of tuples( current_left_up_corner_row, current_left_up_corner_col, old_left_up_corner_row, old_left_up_corner_col, height_tile, width_tile)

Returns:

Type Description
np.ndarray

Output image.