VerticalFlip

Targets:
image
mask
bboxes
keypoints
volume
mask3d
Image Types:uint8, float32

Flip the input vertically around the x-axis.

Arguments
p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.array([
...     [[1, 2, 3], [4, 5, 6]],
...     [[7, 8, 9], [10, 11, 12]]
... ])
>>> transform = A.VerticalFlip(p=1.0)
>>> result = transform(image=image)
>>> flipped_image = result['image']
>>> print(flipped_image)
[[[ 7  8  9]
  [10 11 12]]
 [[ 1  2  3]
  [ 4  5  6]]]
# The original image is flipped vertically, with rows reversed
Notes
  • This transform flips the image upside down. The top of the image becomes the bottom and vice versa.
  • The dimensions of the image remain unchanged.
  • For multi-channel images (like RGB), each channel is flipped independently.
  • Bounding boxes are adjusted to match their new positions in the flipped image.
  • Keypoints are moved to their new positions in the flipped image.