{ "info": { "author": "Yusuke Uchida", "author_email": "ren4yu@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# imgcrop\nSimple image augmentation library focusing on random geometric cropping.\nDifferent from pipeline-based augmentation libraries, this library efficiently performs cropping and geometric transformations at once.\nAs image processing functions such as adding Gaussian noise, blurring, and contrast adjustment are not provided,\nplease use the other great libraries like [imgaug](https://github.com/aleju/imgaug) [1], [Augmentor](https://github.com/mdbloice/Augmentor) [2], and [albumentations](https://github.com/albu/albumentations) [3]\nto further transform images cropped by this library.\n\n![](fig/all1.png?raw=true)\n\n## Features\n\n- Simple API, easy to use\n- Efficient; cropping and all geometric transformations are performed at once (by a single perspective transformation)\n- Guarantee that all pixels in cropped image are taken from inside the original image (if margin is not used)\n\n\n## Installation\n\n```bash\npip install imgcrop\n```\n\n## APIs\n\n### imgcrop.get_cropper\n```python\nget_cropper(patch_size=128, scale=(1.0, 1.0), rotate=(0, 0), distort=0.0, flip=0.0, margin=0)\n```\n\n#### parameters\n- **patch_size**: *int, default 128*\n - output patch size (in pixel)\n- **scale**: *tuple of float, default (1.0, 1.0)*\n - sampling scale range\n- **rotate**: *tuple of int, default (0, 0)*\n - sampling rotation range (in degree)\n- **distort**: *float, default 0.0*\n - distortion strength in perspective transformation (ratio to output image scale)\n- **flip**: *float, default 0.0*\n - horizontal flip probability\n- **margin**: *int, default 0*\n - margin in cropping around original image\n\n#### returns\n- **random_crop**: function\n\n\n### random_crop\n```python\nrandom_crop(img, points=None) -> cropped_img[, output_points], src_points, m\n```\n\n#### parameters\n- **img**: *numpy array (single image) or list of numpy arrays (multiple images)*\n - input image(s) to be cropped with the same geometric transformation\n- **points**: *numpy array with the shape (point_num, 2), default None*\n - input points to be transformed with the same transformation matrix as input image(s)\n\n#### returns\n- **cropped_img**: *numpy array or list of numpy arrays)*\n - cropped output image(s)\n- **output_points**: *numpy array with the shape (point_num, 2)*\n - output points if input points are given\n- **src_points**: *numpy array*\n - points defining the cropped region in the input image(s)\n- **m**: *numpy array*\n - 3x3 perspective transformation matrix from the input image(s) to the output image(s)\n\n## Example\n\nPleaes run or refer to [the example script](example/example.py) to see how this library works:\n\n```bash\npython example/example.py\n```\n\nYou can easily try different parameters by arguments:\n\n```bash\noptional arguments:\n -h, --help show this help message and exit\n --patch_size PATCH_SIZE\n output patch image size (default: 256)\n --scale SCALE SCALE scale range in sampling (default: [0.8, 1.2])\n --rotate ROTATE ROTATE\n rotation range in sampling (default: [-60, 60])\n --distort DISTORT distortion strength for perspective transformation\n (default: 0.2)\n --flip FLIP horizontal flip probability (default: 0.5)\n --margin MARGIN margin around original image (default: 0)\n```\n\n| parameters | cropping results (input, cropped, mask, keypoints) |\n| --- | --- |\n| scaling | ![](fig/scale1.png?raw=true) |\n| | ![](fig/scale2.png?raw=true) |\n| | ![](fig/scale3.png?raw=true) |\n| rotation + scaling | ![](fig/rotate1.png?raw=true) |\n| | ![](fig/rotate2.png?raw=true) |\n| | ![](fig/rotate3.png?raw=true) |\n| distortion + scaling | ![](fig/distort1.png?raw=true) |\n| | ![](fig/distort2.png?raw=true) |\n| | ![](fig/distort3.png?raw=true) |\n| flip + rotation | ![](fig/flip1.png?raw=true) |\n| | ![](fig/flip2.png?raw=true) |\n| | ![](fig/flip3.png?raw=true) |\n| margin + scaling | ![](fig/margin1.png?raw=true) |\n| | ![](fig/margin2.png?raw=true) |\n| | ![](fig/margin3.png?raw=true) |\n| all | ![](fig/all1.png?raw=true) |\n| | ![](fig/all2.png?raw=true) |\n| | ![](fig/all3.png?raw=true) |\n\n## Algorithm\nPatch region in the original image is defined by a set of four points.\nThese points are randomly transformed according to transformation parameters.\nThe transformation matrix from input image to output image is then calculated using these points.\nFinally, cropping is performed by applying perspective transformation.\n\n![](fig/algorithm.png?raw=true)\n\n## References\n1. imgaug, https://github.com/aleju/imgaug\n2. Augmentor, https://github.com/mdbloice/Augmentor\n3. albumentations, https://github.com/albu/albumentations\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yu4u/imgcrop", "keywords": "augmentation,image,deep learning,neural network,machine learning", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "imgcrop", "package_url": "https://pypi.org/project/imgcrop/", "platform": "", "project_url": "https://pypi.org/project/imgcrop/", "project_urls": { "Homepage": "https://github.com/yu4u/imgcrop" }, "release_url": "https://pypi.org/project/imgcrop/0.1.0/", "requires_dist": [ "numpy", "opencv-python" ], "requires_python": "", "summary": "Simple image augmentation library focusing on random geometric cropping.", "version": "0.1.0" }, "last_serial": 4397116, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "903bb55afdcc6169b9ce503d5064ce2b", "sha256": "0fc7dc3d61a5c3c37addcfccaf2f490b0e9d8b99123e4b3bce6e3d0670a70ebc" }, "downloads": -1, "filename": "imgcrop-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "903bb55afdcc6169b9ce503d5064ce2b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4870, "upload_time": "2018-10-20T12:52:48", "url": "https://files.pythonhosted.org/packages/fc/1d/b9d85582cd6a71fd13990206f0ab183fae82fa9a2a0a74e5d4b158c50908/imgcrop-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5dc1aa76babc76250d1b0a1aeaac6b1d", "sha256": "360649c4b00ad85c42a002da58d87c05b008c4f8d759ea67407c4966a2bf88be" }, "downloads": -1, "filename": "imgcrop-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5dc1aa76babc76250d1b0a1aeaac6b1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4101, "upload_time": "2018-10-20T12:52:50", "url": "https://files.pythonhosted.org/packages/60/83/73c5f3a458a65b404c7f1643d06bc9d4d07c9adc53f89952e293a44d0eb3/imgcrop-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "903bb55afdcc6169b9ce503d5064ce2b", "sha256": "0fc7dc3d61a5c3c37addcfccaf2f490b0e9d8b99123e4b3bce6e3d0670a70ebc" }, "downloads": -1, "filename": "imgcrop-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "903bb55afdcc6169b9ce503d5064ce2b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4870, "upload_time": "2018-10-20T12:52:48", "url": "https://files.pythonhosted.org/packages/fc/1d/b9d85582cd6a71fd13990206f0ab183fae82fa9a2a0a74e5d4b158c50908/imgcrop-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5dc1aa76babc76250d1b0a1aeaac6b1d", "sha256": "360649c4b00ad85c42a002da58d87c05b008c4f8d759ea67407c4966a2bf88be" }, "downloads": -1, "filename": "imgcrop-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5dc1aa76babc76250d1b0a1aeaac6b1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4101, "upload_time": "2018-10-20T12:52:50", "url": "https://files.pythonhosted.org/packages/60/83/73c5f3a458a65b404c7f1643d06bc9d4d07c9adc53f89952e293a44d0eb3/imgcrop-0.1.0.tar.gz" } ] }