Skip to main content

imaugtools contains tools used for image augmentation: translate, rotate, crop. This library is for you if you do NOT want to stretch or skew, or pad pixels when doing any of these operations.

Project description


imaugtools contains tools used for image augmentation: translate, rotate, crop. This library is for you if you do NOT want to stretch or skew, or pad pixels that would make your images look strange when doing any of these operations.


To install imaugtools, simply run in your terminal

pip install imaugtools


Example image



my_image_translated = translate_image(my_image, 0.1, 0.2)
my_image_translated_uncropped = translate_image(my_image, 0.1, 0.2, crop=False)
imshow(my_image_translated, my_image_translated_uncropped, mode='BGR')



my_image_rotated = rotate_image(my_image, 30) # angle in degrees
my_image_rotated_uncropped = rotate_image(my_image, 30, crop=False)
imshow(my_image_rotated, my_image_rotated_uncropped, mode='BGR')



my_image_center_cropped = center_crop(my_image, (150, 200))
my_image_cropped_around_center = crop_around_center(my_image, (150, 200))
imshow(my_image_center_cropped, my_image_cropped_around_center, mode='BGR')


print(my_image_center_cropped.shape, my_image_cropped_around_center.shape)
# Output: (200, 200, 3) (200, 200, 3)


  • Import the above functions from imaugtools like,
from imaugtools import translate_image, rotate_image
  • imshow function used here is from imshowtools library

Advanced Usage

Strided Translation

Strided translation is very powerful image augmentation techniques used in training neural networks.

tx_max = 1 and ty_max = 1 is equivalent to a stride of 1 in both directions. After you specify tx_max, you can specify tx (translation in x-axis) from -tx_max to +tx_max. The same applies to ty and ty_max.

my_images_translated = []
for j in range(-1, 2):
    for i in range(-1, 2):
        my_images_translated.append(translate_image(my_image, i, j, tx_max=1, ty_max=1))
imshow(*my_images_translated, mode='BGR')


tx_max = 0.5 and ty_max = 0.5 is equivalent to a stride of 0.5 in both directions

my_images_translated = []
for j in range(-2, 3):
    for i in range(-2, 3):
        my_images_translated.append(translate_image(my_image, i/4, j/4, tx_max=0.5, ty_max=0.5))
imshow(*my_images_translated, mode='BGR')



Pull requests are very welcome.

  1. Fork the repo
  2. Create new branch with feature name as branch name
  3. Check if things work with a jupyter notebook
  4. Raise a pull request


Please see attached Licence

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for imaugtools, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size imaugtools-0.1.0-py3-none-any.whl (7.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size imaugtools-0.1.0.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page