{"id":15356370,"url":"https://github.com/saravanabalagi/imaugtools","last_synced_at":"2025-04-15T06:40:58.903Z","repository":{"id":62570590,"uuid":"215524941","full_name":"saravanabalagi/imaugtools","owner":"saravanabalagi","description":"Tools used for aspect-ratio-preserving image augmentation, namely translate, rotate, crop WITHOUT stretching or skewing the image, or padding pixels to fill up empty space.","archived":false,"fork":false,"pushed_at":"2020-06-02T12:24:42.000Z","size":2258,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T17:11:15.778Z","etag":null,"topics":["image-augmentation","image-cropping","image-processing","image-processing-library","image-rotation","image-translation"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/imaugtools","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saravanabalagi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-16T10:51:13.000Z","updated_at":"2024-02-04T10:42:35.000Z","dependencies_parsed_at":"2022-11-03T17:46:31.276Z","dependency_job_id":null,"html_url":"https://github.com/saravanabalagi/imaugtools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fimaugtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fimaugtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fimaugtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanabalagi%2Fimaugtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saravanabalagi","download_url":"https://codeload.github.com/saravanabalagi/imaugtools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023723,"owners_count":21199958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-augmentation","image-cropping","image-processing","image-processing-library","image-rotation","image-translation"],"created_at":"2024-10-01T12:28:31.120Z","updated_at":"2025-04-15T06:40:58.887Z","avatar_url":"https://github.com/saravanabalagi.png","language":"Jupyter Notebook","readme":"# imaugtools\n\n![](https://img.shields.io/pypi/v/imaugtools)\n![](https://img.shields.io/pypi/wheel/imaugtools)\n![](https://img.shields.io/pypi/l/imaugtools)\n![](https://img.shields.io/pypi/dm/imshowtools)\n\nimaugtools 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.\n\n## Installation\n\nTo install imaugtools, simply run in your terminal\n```sh\npip install imaugtools\n```\n\n## Usage\n\nExample image\n\n![example-image](https://github.com/saravanabalagi/imaugtools/raw/master/example/lenna_small.png)\n\n### Translation\n\n```py\nfrom imaugtools import translate_image\nmy_image_translated = translate_image(my_image, 0.1, 0.2)\nmy_image_translated_uncropped = translate_image(my_image, 0.1, 0.2, crop=False)\nimshow(my_image_translated, my_image_translated_uncropped, mode='BGR')\n```\n`imshow` function used here is to simply display the images, you can use it from [imshowtools](https://github.com/saravanabalagi/imshowtools) library.\n\nWith and without crop:\n\n![translated-image](https://github.com/saravanabalagi/imaugtools/raw/master/example/lenna_translated.png)\n\n### Rotation\n\n```py\nfrom imaugtools import rotate_image\nmy_image_rotated = rotate_image(my_image, 30) # angle in degrees\nmy_image_rotated_uncropped = rotate_image(my_image, 30, crop=False)\nimshow(my_image_rotated, my_image_rotated_uncropped, mode='BGR')\n```\nWith and without crop:\n\n![rotated-image](https://github.com/saravanabalagi/imaugtools/raw/master/example/lenna_rotated.png)\n\n### Cropping\n\n```py\nfrom imaugtools import center_crop, crop_around_center\nmy_image_center_cropped = center_crop(my_image, (150, 200))\nmy_image_cropped_around_center = crop_around_center(my_image, (150, 200))\nimshow(my_image_center_cropped, my_image_cropped_around_center, mode='BGR')\n```\n\nAspect ratio preserving center crop and crop around center:\n\n![cropped-image](https://github.com/saravanabalagi/imaugtools/raw/master/example/lenna_cropped.png)\n\n```py\nprint(my_image_center_cropped.shape, my_image_cropped_around_center.shape)\n# Output: (150, 200, 3) (150, 200, 3)\n```\n\n## Advanced Usage\n\n### Strided Translation\n\nStrided translation is one of the powerful image augmentation techniques used in training neural networks.\n\n`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`.\n\n```py\nmy_images_translated = []\nfor j in range(-1, 2):\n    for i in range(-1, 2):\n        my_images_translated.append(translate_image(my_image, i, j, tx_max=1, ty_max=1))\nimshow(*my_images_translated, mode='BGR')\n```\n![stride-1-translation](https://github.com/saravanabalagi/imaugtools/raw/master/example/lenna_stride_1.png)\n\n\n\n`tx_max = 0.5` and `ty_max = 0.5` is equivalent to a stride of 0.5 in both directions\n\n```py\nmy_images_translated = []\nfor j in range(-2, 3):\n    for i in range(-2, 3):\n        my_images_translated.append(translate_image(my_image, i/4, j/4, tx_max=0.5, ty_max=0.5))\nimshow(*my_images_translated, mode='BGR')\n```\n![stride-0.5-translation](https://github.com/saravanabalagi/imaugtools/raw/master/example/lenna_stride_0.5.png)\n\n\n## Contributing\n\nPull requests are very welcome.\n\n1. Fork the repo\n1. Create new branch with feature name as branch name\n1. Check if things work with a jupyter notebook\n1. Raise a pull request\n\n## Licence\n\nPlease see attached [Licence](https://github.com/saravanabalagi/imaugtools/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaravanabalagi%2Fimaugtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaravanabalagi%2Fimaugtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaravanabalagi%2Fimaugtools/lists"}