{"id":26658233,"url":"https://github.com/dakshvar22/image-transformer","last_synced_at":"2025-04-11T13:07:57.645Z","repository":{"id":84594021,"uuid":"116559154","full_name":"dakshvar22/Image-Transformer","owner":"dakshvar22","description":"Python library to apply transformations to images and regions of interests with images specifically using opencv ","archived":false,"fork":false,"pushed_at":"2018-03-21T05:40:25.000Z","size":89,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T09:19:01.125Z","etag":null,"topics":["computer-vision","opencv","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/dakshvar22.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-01-07T11:17:40.000Z","updated_at":"2021-02-07T03:09:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"73cc5a44-2318-4753-8c78-26207bede465","html_url":"https://github.com/dakshvar22/Image-Transformer","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/dakshvar22%2FImage-Transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakshvar22%2FImage-Transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakshvar22%2FImage-Transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakshvar22%2FImage-Transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dakshvar22","download_url":"https://codeload.github.com/dakshvar22/Image-Transformer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248404558,"owners_count":21097772,"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":["computer-vision","opencv","python"],"created_at":"2025-03-25T09:19:06.884Z","updated_at":"2025-04-11T13:07:57.633Z","avatar_url":"https://github.com/dakshvar22.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image Transformer\n\nThis python library helps you apply a diverse combination of affine transformations on an image. Moreover, it gives you the flexibility to apply the exact same transformation on a set of synthetic points over the image(For eg - bounding boxes for image localization task). Such transformations are extremely helpful in AI related tasks specially where the training corpus is small and needs to be augmented with these transformed images.\n\nAvailable Transforms - \n\n1. Horizontal Flip\n2. Vertical Flip\n3. Translate in x\n4. Translate in y\n5. Rotation\n6. Shear Transform\n\n## Requirements and installation\n\nRequired Packages - \n\n1. OpenCV - Currently tested with 2.4.11\n\nTo install, navigate to the root folder and run - \n\n`\npip install -e .\n` \n\n## Usage\n\n```python\n\n# Import\nfrom imgTransformer import Transformer\nimport cv2\n\n# Instantiation\ndata_transformer = Transformer(transform_boxes = True)\n'''\nparameter transform_boxes lets you specify if you want to suppy the corresponding bounding box annotations as well and get the transformed boxes too. Defaults to False\n'''\n\n# Affine transformation parameters\ntx_range = (-20,20)\t# Translate in x direction by n pixels where n is picked randomly from the range - (-20,20)\nty_range = (-20,20)\t# Translate in y direction by n pixels where n is picked randomly from the range - (-20,20)\nrot_range = (-30,30) # Rotate by an angle theta where theta is picked randomly from the range - (-30,30)\nshear_range = 5 # Apply a shear transform with shear coefficient being 5\n\n# Supply these parameters to the data_transformer object\ndata_transformer.set_params(tx_range,ty_range,rot_range,shear_range)\n\n# Load an image\nimg = cv2.imread('0.JPEG') # numpy matrix with dimensions - (height,width,channels)\n\n'''\nSpecify bounding boxes(dummy box taken here)\nA list of list where each bounding boxes is a list of size 4 with elements(in order) - \n\n1. X coordinate of top left vertex\n2. Y coordinate of top left vertex\n3. X coordinate of bottom right vertex\n4. Y coordinate of bottom right vertex\n\n'''\nboxes = [[132, 85, 251, 275]] # dummy box\n\n# Apply the transform\nimg_trans, boxes_trans = data_transformer.applyTransforms(img,boxes,num_transforms = 2) # num_transforms specifies how many consecutive affine transformations should be applied.\n\n# draw the bounding boxes for visualization\ncv2.rectangle(img,(boxes[0][0],boxes[0][1]),(boxes[0][2],boxes[0][3]),color = (255,0,0))\ncv2.rectangle(img_trans,(boxes_trans[0][0],boxes_trans[0][1]),(boxes_trans[0][2],boxes_trans[0][3]),color = (255,0,0))\n\n# Store the files - \ncv2.imwrite('original.JPEG',img)\ncv2.imwrite('transformed.JPEG',img_trans)\n\n```\n\n## Result\n\nOriginal\n![alt text][Original]\n\nTransformed\n![alt text][Transformed]\n\n[Original]: original.JPEG \"Original\"\n[Transformed]: transformed.JPEG \"Transformed\"\n\nThe above mentioned transformations are applied completely randomly so a different run of test.py can result in a different transformed image from what is shown above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdakshvar22%2Fimage-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdakshvar22%2Fimage-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdakshvar22%2Fimage-transformer/lists"}