Didier
Didier

Reputation: 11

ImageDataGenerator how to change the range of the rotation?

It is possible to do a roation between $theta_{min}$ and $theta_{max}$?

ImageDataGenerator(rotation_range=90) rotate the images with a random angle between 0 and 90 degrees it is possible for example to rotate between 50 and 60 degrees?

Upvotes: 0

Views: 11337

Answers (2)

xzhhzx
xzhhzx

Reputation: 41

Actually, Didier is right, 'rotation_range=90' means randomly rotate between [-90,90].

If you want to rotate for a fixed angle, I think you should try manually writing a function, which is corresponding to the parameter 'preprocessing_function' in ImageDataGenerator.

'preprocessing_function' could actually perform a lot of transforms, much flexible!

Hope this could help you!

Upvotes: 4

yusisc
yusisc

Reputation: 9

In keras, ImageDataGenerator(rotation_range=90) does not rotate images with random angles between 0 degree and 90 degree. The random angle range is -90 degree and 90 degree.

# from ..../Anaconda3/Lib/site-packages/keras/preprocessing/image.py if self.rotation_range: theta = np.deg2rad(np.random.uniform(-self.rotation_range, self.rotation_range)) else: theta = 0

What you want may be ImageDataGenerator(rotation_range=20) to random rotate images with random angles between -20 degree and 20 degree.

Upvotes: 0

Related Questions