{ "info": { "author": "Le Quang Nhat", "author_email": "nhat.le@f4.intek.edu.vn", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "

Sprite Detection

\n\n\n\n\n### Features\n\n- [x] Find the Most Common Color in an Image.\n- [x] Find Sprites in an Image.\n- [x] Draw Sprite Label Bounding Boxes.\n\n### Why this project is useful?\n\n- Used reasonable library for process Image.\n- Can be used on a big image.\n- Easy to understand.\n\n### Usage\n\n- Find the Most Common Color in an Image\n\n```python\n>>> from PIL import Image\n# JPEG image\n>>> image = Image.open('first_image.jpg')\n>>> image.mode\n'RGB'\n>>> find_most_common_color(image)\n(0, 221, 204)\n# PNG image\n>>> image = Image.open('second_image.png')\n>>> image.mode\n'RGBA'\n>>> find_most_common_color(image)\n(0, 0, 0, 0)\n# Grayscale image\n>>> image = image.convert('L')\n>>> image.mode\n'L'\n>>> find_most_common_color(image)\n0\n```\n\n- Find Sprites in an Image.\n\n\n\n```python\n>>> from PIL import Image\n>>> image = Image.open('metal_slug_single_sprite.png')\n>>> sprites, label_map = find_sprites(image, background_color=(255, 255, 255))\n>>> len(sprites)\n1\n>>> for label, sprite in sprites.items():\n... print(f\"Sprite ({label}): [{sprite.top_left}, {sprite.bottom_right}] {sprite.width}x{sprite.height}\")\nSprite (1): [(0, 0), (29, 37)] 30x38\n>>> import pprint\n>>> pprint.pprint(label_map, width=120)\n[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1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1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0]]\n```\nOther example with the following image:\n\n\n\n```python\n>>> from PIL import Image\n>>> image = Image.open('optimized_sprite_sheet.png')\n>>> sprites, label_map = find_sprites(image)\n>>> len(sprites)\n22\n>>> for label, sprite in sprites.items():\n... print(f\"Sprite ({label}): [{sprite.top_left}, {sprite.bottom_right}] {sprite.width}x{sprite.height}\")\nSprite (25): [(383, 1), (455, 102)] 73x102\nSprite (43): [(9, 2), (97, 122)] 89x121\nSprite (26): [(110, 4), (195, 123)] 86x120\nSprite (46): [(207, 4), (291, 123)] 85x120\nSprite (16): [(305, 8), (379, 123)] 75x116\nSprite (53): [(349, 125), (431, 229)] 83x105\nSprite (61): [(285, 126), (330, 181)] 46x56\nSprite (100): [(1, 129), (101, 237)] 101x109\nSprite (106): [(106, 129), (193, 249)] 88x121\nSprite (93): [(183, 137), (278, 241)] 96x105\nSprite (95): [(268, 173), (355, 261)] 88x89\nSprite (178): [(6, 244), (101, 348)] 96x105\nSprite (185): [(145, 247), (245, 355)] 101x109\nSprite (141): [(343, 257), (417, 372)] 75x116\nSprite (169): [(102, 262), (142, 303)] 41x42\nSprite (188): [(249, 267), (344, 373)] 96x107\nSprite (192): [(412, 337), (448, 372)] 37x36\nSprite (256): [(89, 353), (184, 459)] 96x107\nSprite (234): [(11, 356), (104, 461)] 94x106\nSprite (207): [(188, 358), (281, 463)] 94x106\nSprite (229): [(384, 374), (456, 475)] 73x102\nSprite (248): [(286, 378), (368, 482)] 83x105\n```\n\n- Draw Sprite Label Bounding Boxes.\n\n```python\n>>> from PIL import Image\n>>> image = Image.open('optimized_sprite_sheet.png')\n>>> sprites, label_map = find_sprites(image)\n>>> # Draw sprite masks and bounding boxes with the default white background color.\n>>> sprite_label_image = create_sprite_labels_image(sprites, label_map)\n>>> sprite_label_image.save('optimized_sprite_sheet_bounding_box_white_background.png')\n>>> # Draw sprite masks and bounding boxes with a transparent background color.\n>>> sprite_label_image = create_sprite_labels_image(sprites, label_map, background_color=(0, 0, 0, 0))\n>>> sprite_label_image.save('optimized_sprite_sheet_bounding_box_transparent_background.png')\n```\n\n| Sprite Masks with White Background | Sprite Masks with Transparent Background |\n| ------------------------------------------------------------- | ------------------------------------------------------------------- |\n| ||\n\n\n### Built with\n- [Pillow](https://pillow.readthedocs.io/en/stable/)\n- [Numpy](https://numpy.org/devdocs/user/quickstart.html)\n\n\n### Pull requests welcome!\nSpotted an error? Something doesn't make sense? Send me a [pull\nrequest](https://github.com/intek-training-jsc/sprite-detection-masternhat/pulls)!\n\n\n### Support\nAsk your question here: \n\n### Everyone can Maintains && Contributing\n\nJust follow steps:\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b feature/fooBar`)\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\n4. Push to the branch (`git push origin feature/fooBar`)\n5. Create a new Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\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/intek-training-jsc/sprite-detection-masternhat", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "test-10", "package_url": "https://pypi.org/project/test-10/", "platform": "", "project_url": "https://pypi.org/project/test-10/", "project_urls": { "Homepage": "https://github.com/intek-training-jsc/sprite-detection-masternhat" }, "release_url": "https://pypi.org/project/test-10/1.0.1/", "requires_dist": [ "numpy", "pillow" ], "requires_python": ">=3.6", "summary": "Sprite detection package", "version": "1.0.1" }, "last_serial": 5994982, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "5d449231c704c1232385b0bf47ca7582", "sha256": "9e91b772cbc1dacf38fc4feef33a4f072c995a988075e2cd2c2f407c3babf282" }, "downloads": -1, "filename": "test_10-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5d449231c704c1232385b0bf47ca7582", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 6882, "upload_time": "2019-10-18T10:39:44", "url": "https://files.pythonhosted.org/packages/cd/7b/401306bd0af5b06585f823525cbc6ed7d5f244cd923ba453b1df00002016/test_10-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a69670fc0b45641c4823b24e3ddee293", "sha256": "537c3999d72f9355b4625432e50a78358d19e21c98838db038105a69a8345d88" }, "downloads": -1, "filename": "test_10-1.0.1.tar.gz", "has_sig": false, "md5_digest": "a69670fc0b45641c4823b24e3ddee293", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 6993, "upload_time": "2019-10-18T10:39:48", "url": "https://files.pythonhosted.org/packages/3c/38/75551274550ebccd78251408d924e751d4b66a6a81735909f6194dd20678/test_10-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5d449231c704c1232385b0bf47ca7582", "sha256": "9e91b772cbc1dacf38fc4feef33a4f072c995a988075e2cd2c2f407c3babf282" }, "downloads": -1, "filename": "test_10-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5d449231c704c1232385b0bf47ca7582", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 6882, "upload_time": "2019-10-18T10:39:44", "url": "https://files.pythonhosted.org/packages/cd/7b/401306bd0af5b06585f823525cbc6ed7d5f244cd923ba453b1df00002016/test_10-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a69670fc0b45641c4823b24e3ddee293", "sha256": "537c3999d72f9355b4625432e50a78358d19e21c98838db038105a69a8345d88" }, "downloads": -1, "filename": "test_10-1.0.1.tar.gz", "has_sig": false, "md5_digest": "a69670fc0b45641c4823b24e3ddee293", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 6993, "upload_time": "2019-10-18T10:39:48", "url": "https://files.pythonhosted.org/packages/3c/38/75551274550ebccd78251408d924e751d4b66a6a81735909f6194dd20678/test_10-1.0.1.tar.gz" } ] }