15

I cant understand what is the effect of shear parameter in ImageDataGenerator of keras

I had tried to use an image to apply the shear by apply_transform member function in ImageDataGenerator. I can see the image seems to be rotated and stretched out after apply this function. But I cant understand what exactly it did.

from keras.preprocessing.image import ImageDataGenerator
import matplotlib.pyplot as plt
import numpy as np

(train_x, train_y) , (test_x,test_Y) = cifar10.load_data()
img = train_x[0]
img_gen = ImageDataGenerator()


shear_intensity = np.arange(0,110,10, dtype = int)

nrow = 4
ncol = 3


plt.figure(figsize = (14,14))
for i,shear in enumerate(shear_intensity):
  plt.title(f'shear intensity : {shear}')
  plt.subplot(nrow, ncol, i+1)
  plt.imshow(img_gen.apply_transform(img, {'shear' : shear}))
plt.show()

The image does have some change, but I cant understand the effect.

Ray Xie
  • 171
  • 1
  • 1
  • 8

1 Answers1

23

'Shear' means that the image will be distorted along an axis, mostly to create or rectify the perception angles. It's usually used to augment images so that computers can see how humans see things from different angles. Shear example

Alexandre Huat
  • 806
  • 10
  • 16
LazyCoder
  • 1,267
  • 5
  • 17