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_flip(bbox, d, rows, cols)
[view source on GitHub]
¶
Flip a bounding box either vertically, horizontally or both depending on the value of d
.
Parameters:
Name | Type | Description |
---|---|---|
bbox |
tuple |
A bounding box |
d |
int |
|
rows |
int |
Image rows. |
cols |
int |
Image cols. |
Returns:
Type | Description |
---|---|
tuple |
A bounding box |
Exceptions:
Type | Description |
---|---|
ValueError |
if value of |
def
albumentations.augmentations.functional.bbox_hflip(bbox, rows, cols)
[view source on GitHub]
¶
Flip a bounding box horizontally around the y-axis.
Parameters:
Name | Type | Description |
---|---|---|
bbox |
tuple |
A bounding box |
rows |
int |
Image rows. |
cols |
int |
Image cols. |
Returns:
Type | Description |
---|---|
tuple |
A bounding box |
def
albumentations.augmentations.functional.bbox_transpose(bbox, axis, rows, cols)
[view source on GitHub]
¶
Transposes a bounding box along given axis.
Parameters:
Name | Type | Description |
---|---|---|
bbox |
tuple |
A bounding box |
axis |
int |
0 - main axis, 1 - secondary axis. |
rows |
int |
Image rows. |
cols |
int |
Image cols. |
Returns:
Type | Description |
---|---|
tuple |
A bounding box tuple |
Exceptions:
Type | Description |
---|---|
ValueError |
If axis not equal to 0 or 1. |
def
albumentations.augmentations.functional.bbox_vflip(bbox, rows, cols)
[view source on GitHub]
¶
Flip a bounding box vertically around the x-axis.
Parameters:
Name | Type | Description |
---|---|---|
bbox |
tuple |
A bounding box |
rows |
int |
Image rows. |
cols |
int |
Image cols. |
Returns:
Type | Description |
---|---|
tuple |
A bounding box |
def
albumentations.augmentations.functional.elastic_transform_approx(img, alpha, sigma, alpha_affine, interpolation=1, border_mode=4, value=None, random_state=None)
[view source on GitHub]
¶
Elastic deformation of images as described in [Simard2003]_ (with modifications for speed). Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5
.. [Simard2003] 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.
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 |
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 array with (h, w, rgb) shape, as ints between 0-255) |
alpha |
|
how much to perturb/scale the eigen vecs and vals the paper used std=0.1 |
Returns:
Type | Description |
---|---|
|
numpy image-like array as float range(0, 1) |
def
albumentations.augmentations.functional.grid_distortion(img, num_steps=10, xsteps=(), ysteps=(), interpolation=1, border_mode=4, value=None)
[view source on GitHub]
¶
Perform a grid distortion of an input image.
Reference: http://pythology.blogspot.sg/2014/03/interpolation-on-regular-distorted-grid.html
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.keypoint_flip(keypoint, d, rows, cols)
[view source on GitHub]
¶
Flip a keypoint either vertically, horizontally or both depending on the value of d
.
Parameters:
Name | Type | Description |
---|---|---|
keypoint |
tuple |
A keypoint |
d |
int |
Number of flip. Must be -1, 0 or 1: * 0 - vertical flip, * 1 - horizontal flip, * -1 - vertical and horizontal flip. |
rows |
int |
Image height. |
cols |
int |
Image width. |
Returns:
Type | Description |
---|---|
tuple |
A keypoint |
Exceptions:
Type | Description |
---|---|
ValueError |
if value of |
def
albumentations.augmentations.functional.keypoint_hflip(keypoint, rows, cols)
[view source on GitHub]
¶
Flip a keypoint horizontally around the y-axis.
Parameters:
Name | Type | Description |
---|---|---|
keypoint |
tuple |
A keypoint |
rows |
int |
Image height. |
cols |
int |
Image width. |
Returns:
Type | Description |
---|---|
tuple |
A keypoint |
def
albumentations.augmentations.functional.keypoint_transpose(keypoint)
[view source on GitHub]
¶
Rotate a keypoint by angle.
Parameters:
Name | Type | Description |
---|---|---|
keypoint |
tuple |
A keypoint |
Returns:
Type | Description |
---|---|
tuple |
A keypoint |
def
albumentations.augmentations.functional.keypoint_vflip(keypoint, rows, cols)
[view source on GitHub]
¶
Flip a keypoint vertically around the x-axis.
Parameters:
Name | Type | Description |
---|---|---|
keypoint |
tuple |
A keypoint |
rows |
int |
Image height. |
cols( |
int |
Image width. |
Returns:
Type | Description |
---|---|
tuple |
A keypoint |
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 |
def
albumentations.augmentations.functional.optical_distortion(img, k=0, dx=0, dy=0, interpolation=1, border_mode=4, value=None)
[view source on GitHub]
¶
Barrel / pincushion distortion. Unconventional augment.
Reference: | https://stackoverflow.com/questions/6199636/formulas-for-barrel-pincushion-distortion | https://stackoverflow.com/questions/10364201/image-transformation-in-opencv | https://stackoverflow.com/questions/2477774/correcting-fisheye-distortion-programmatically | http://www.coldvision.io/2017/03/02/advanced-lane-finding-using-opencv/
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.preserve_channel_dim(func)
[view source on GitHub]
¶
Preserve dummy channel dim.
def
albumentations.augmentations.functional.preserve_shape(func)
[view source on GitHub]
¶
Preserve shape of the image
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. |