NEW
All annotation is now free in Hasty.

Shear

If you have ever worked on a Computer Vision project, you might know that using augmentations to diversify the dataset is the best practice. On this page, we will:

  • Сover the Shear augmentation;

  • Check out its parameters;

  • See how Shear affects an image;

  • And check out how to work with Shear using Python through the Albumentations library.

Let’s jump in.

Shear explained

To define the term, Shear is a geometric augmentation that changes a form of an image along a specific axis to create a different perception angle.

Image source: Quora

As you can see in the picture above, Shear moves a side of an image, transforming its initial form of a square into a trapezoid. Shears are applied sequentially if you want to shear your image along the x- and y-axis. Data Scientists use Shear to augment pictures in such a way that an algorithm can identify an object from multiple angles.

Parameters

  • Shear in degrees - specifies the range of degrees that is used to sample x- and y-shear angle values;
  • Probability of applying transform - defines the likelihood of applying Shear to an image.

Shear visualized

Original image
Image after the Shear augmentation is applied with the (-45, 45) degrees parameters

Code implementation

import albumentations as albu
from PIL import Image
import numpy as np


transform = albu.augmentations.geometric.transforms.Affine(shear = {'x': -45, 'y': 45})
image = np.array(Image.open('/some/random/image.png'))
augmented_image = transform(image=image)['image']

# We have the transformed image in augmented_image.

Learn more about other augmentations …

Last updated on Jul 11, 2022

Removing the risk from vision AI.

Only 13% of vision AI projects make it to production, with Hasty we boost that number to 100%.