{ "info": { "author": "Christelle Cocco, Raphael Cere, Aris Xanthos", "author_email": "christelle.cocco@unil.ch", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering" ], "description": "\n# Color-extraction\n\nColor-extraction is an open-source python module which attributes to each element of an ndarray (RGB image) the most similar color from a palette of predefined colors.\n\nThree functions are included, each of which takes an RGB ndarray as input and returns a dict whose keys are the names of each predefined color:\n\nFunction | Values of returned dict\n--- | ---\n[`get_bool_arrays`](#boolean-arrays) | boolean ndarrays (1 per color)\n[`get_rgb_arrays`](#rgb-arrays) | RGB ndarrays (1 per color)\n[`get_counts`](#pixel-counts) | integer counts of pixels (1 per color)\n\n## Installing\n\n```\n>>> pip install color_extraction\n```\n\n## Usage examples\n\nA predefined set of colors is included in the module with ten colors: red,\norange, yellow, green, cyan, blue, purple, pink, achromatic (gray and black),\nand white. This set of colors, which can be modified, is available at\n[https://github.com/ChrisCocco/ddd_colours/blob/master/color_extraction/color_definitions.json](https://github.com/ChrisCocco/ddd_colours/blob/master/color_extraction/color_definitions.json).\n\nTo get started:\n```\n>>> import color_extraction\n>>> import matplotlib\n>>> import matplotlib.pyplot\n\n>>> with matplotlib.cbook.get_sample_data('ada.png') as image_file:\n... img = matplotlib.pyplot.imread(image_file)\n```\n\n### Boolean arrays\n\nThe function `get_bool_arrays` returns a dictionary with a boolean ndarray for each color. Each such array has the same horizontal and vertical dimensions as the source image and can be thought of as a *mask* for the color in question.\n\n```\n>>> dict_bool_arrays = color_extraction.get_bool_arrays(img)\n\n>>> for color in dict_bool_arrays.keys():\n matplotlib.image.imsave(output_path+color, dict_bool_arrays[color], cmap='gray')\n```\n\nOriginal image| white | red | orange\n--- | --- | --- | ---\n![Original image](color_extraction/img/ada.png) | ![White](color_extraction/img/bool_white.png)| ![Red](color_extraction/img/bool_red.png) | ![Orange](color_extraction/img/bool_orange.png)\nyellow | green | cyan | blue\n![Yellow](color_extraction/img/bool_yellow.png)|![Green](color_extraction/img/bool_green.png)|![Cyan](color_extraction/img/bool_cyan.png)|![Blue](color_extraction/img/bool_blue.png)\npurple |pink | achromatic\n![Purple](color_extraction/img/bool_purple.png)|![White](color_extraction/img/bool_pink.png)|![Achromatic](color_extraction/img/bool_achro.png)\n\nIt is also possible to use a median filter (3 x 3) in order to reduce the amount of pixels of a given color that are isolated in the array:\n\n```\n>>> color_extraction.get_bool_arrays(img, median_filter=True)\n```\n\nIt is also possible to use your own color definitions saved in a JSON file.\n\n```\n>>> color_extraction.get_bool_arrays(img, color_def_path=path_to_your_json_file)\n```\n\n### RGB arrays\n\nThe function `get_rgb_arrays` returns a dictionary with a RGB array for each color. Each such array has the same horizontal and vertical dimensions as the source image. Positions where the color in question has been detected contain the original RGB color found in the source image; other positions have the value 0 (black), except in the case of the \"achro(matic)\" color, where they have the value 1 (white).\n\n```\n>>> dict_rgb_arrays = color_extraction.get_rgb_arrays(img)\n\n>>> for color in dict_rgb_arrays:\n... matplotlib.image.imsave(color, dict_rgb_arrays[color])\n```\n\n\n\nUsing the following image as input:\n\nOriginal image| white | red | orange\n--- | --- | --- | ---\n![Original image](color_extraction/img/ada.png) | ![White](color_extraction/img/white.png)| ![Red](color_extraction/img/red.png) | ![Orange](color_extraction/img/orange.png)\nyellow | green | cyan | blue\n![Yellow](color_extraction/img/yellow.png)|![Green](color_extraction/img/green.png)|![Cyan](color_extraction/img/cyan.png)|![Blue](color_extraction/img/blue.png)\npurple |pink | achromatic\n![Purple](color_extraction/img/purple.png)|![White](color_extraction/img/pink.png)|![Achromatic](color_extraction/img/achro.png)\n\nSimilarly to [`get_bool_arrays`](#boolean-arrays), it is possible to use a median filter and/or your own color definition set, with the same parameters (`median_filter` and `color_def_path`).\n\n### Pixel counts\n\nThe function `get_counts` returns a dictionary with the number of pixels of each colour.\n\n```\n>>> color_extraction.get_counts(img)\n{'purple': 25, 'blue': 6652, 'achro': 2477505, 'cyan': 764, 'white': 9567, 'green': 185, 'red': 114555, 'pink': 163, 'orange': 150263, 'yellow': 5121}\n```\nSimilarly to [`get_bool_arrays`](#boolean-arrays), it is possible to use your own color definition set, with the same parameter (`color_def_path`). The median filter is not available for this function.\n\n## Dependencies\n\n* scipy.cluster.vq\n* skimage.filters\n* numpy\n\n## Authors\n\n* [Christelle Cocco](https://github.com/ChrisCocco) - initial implementation\n* [Rapha\u00ebl Cer\u00e9](https://github.com/raphaelcere) - contributor\n* [Aris Xanthos](https://github.com/axanthos) - refactoring\n\n## Credits\nThis module was partially funded by the the Swiss National Science Foundation (SNSF), grant N\u00b0 CR11I1_156383.\n\nThe current version (0.1a0) was implemented by Aris Xanthos based on the original code by Christelle Cocco available [here](color_extraction/fct_palette_man_RGB.py).\n\nTo cite: [Cocco, C., Cer\u00e9, R., Xanthos, A., Brandt, P.-Y. 2019. _Identification and quantification of colours in children's drawings_. Workshop on Computational Methods in the Humanities 2018. pp. 11-21. Vol. 2314. CEUR Workshop Proceedings](http://ceur-ws.org/Vol-2314/paper1.pdf)\n\n## License\n\nThis project is licensed under the GNU General Public License v3 - see the [LICENSE](LICENSE) file for details.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ChrisCocco/ddd_colours", "keywords": "", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "color-extraction", "package_url": "https://pypi.org/project/color-extraction/", "platform": "", "project_url": "https://pypi.org/project/color-extraction/", "project_urls": { "Homepage": "https://github.com/ChrisCocco/ddd_colours" }, "release_url": "https://pypi.org/project/color-extraction/0.1a3/", "requires_dist": [ "numpy", "scipy", "scikit-image", "matplotlib" ], "requires_python": "", "summary": "A python package for decomposing an image into basic colours", "version": "0.1a3" }, "last_serial": 4763931, "releases": { "0.1a0": [ { "comment_text": "", "digests": { "md5": "2838b24113ea9babb1943cd0cc0b3a53", "sha256": "a1d8f1934c8649701736f7769b1aea5ff243bbafa7414ea56d2f57673b446dd5" }, "downloads": -1, "filename": "color_extraction-0.1a0-py3-none-any.whl", "has_sig": false, "md5_digest": "2838b24113ea9babb1943cd0cc0b3a53", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11375, "upload_time": "2019-01-29T10:03:32", "url": "https://files.pythonhosted.org/packages/8e/cf/0bdc0396f52b6492061f802ef79abce91d6c4d30099cbd23ee3c07ce3116/color_extraction-0.1a0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1134b85983ed81ab17a2dc4407faa77c", "sha256": "ea129c38bf533871f7cd337af965df68ead12f97af5cd70dd4d9189f311f0639" }, "downloads": -1, "filename": "color_extraction-0.1a0.tar.gz", "has_sig": false, "md5_digest": "1134b85983ed81ab17a2dc4407faa77c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7761, "upload_time": "2019-01-29T10:04:06", "url": "https://files.pythonhosted.org/packages/20/17/39aab797444058a5102c6feb319630ea343b0c7bd5b318ec9223be653b20/color_extraction-0.1a0.tar.gz" } ], "0.1a1": [ { "comment_text": "", "digests": { "md5": "c9549d93d90e86cf278c83e41e1ec7ab", "sha256": "45042512ba4341e4a208c4c60b93b0e4f6c3fe6032dac11f773e5ec36da344ea" }, "downloads": -1, "filename": "color_extraction-0.1a1-py3-none-any.whl", "has_sig": false, "md5_digest": "c9549d93d90e86cf278c83e41e1ec7ab", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7522, "upload_time": "2019-01-31T14:07:13", "url": "https://files.pythonhosted.org/packages/e1/63/a91d98c4ff8fbf243b31acb2cbd3a94476960efdca7b87d8470aabf72436/color_extraction-0.1a1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b46f64118073e7cbfd91d4091940348", "sha256": "771e2dfa99b1ecff7ed33490514de46e7eb5c82ac6357ed6745d74e54e37d547" }, "downloads": -1, "filename": "color_extraction-0.1a1.tar.gz", "has_sig": false, "md5_digest": "3b46f64118073e7cbfd91d4091940348", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7461, "upload_time": "2019-01-31T14:07:36", "url": "https://files.pythonhosted.org/packages/da/dd/f1e7941599fb1653e9e860be2d21d8ededef79f1ea049433506ea4a80345/color_extraction-0.1a1.tar.gz" } ], "0.1a2": [ { "comment_text": "", "digests": { "md5": "e9b81f20c01334b5041630e94825bddb", "sha256": "900fcff3538422a8f9f079b1473a88961ad8ba2dfa8bf93110b138893af229e0" }, "downloads": -1, "filename": "color_extraction-0.1a2-py3-none-any.whl", "has_sig": false, "md5_digest": "e9b81f20c01334b5041630e94825bddb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11429, "upload_time": "2019-01-31T14:17:17", "url": "https://files.pythonhosted.org/packages/af/de/7c12e51201dce4fbe0367764770b0a20336e01109c212ffe667f1af3c772/color_extraction-0.1a2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36651830ebf1234f5933590be14f9998", "sha256": "6c192bb1d539f9ebb91fa2cf8a90857742ef2025be4c095828e8783f6bc9e027" }, "downloads": -1, "filename": "color_extraction-0.1a2.tar.gz", "has_sig": false, "md5_digest": "36651830ebf1234f5933590be14f9998", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7809, "upload_time": "2019-01-31T14:17:44", "url": "https://files.pythonhosted.org/packages/10/c6/159bb9d8e72c3682b384d68bf81a1fcaee43827df34d624a471ac559f63c/color_extraction-0.1a2.tar.gz" } ], "0.1a3": [ { "comment_text": "", "digests": { "md5": "71abf66b655c3e572bd5773711dff691", "sha256": "39c143d3c22c3fbe4208957abf1dc7056600d5be4a56aec719579de0e471c206" }, "downloads": -1, "filename": "color_extraction-0.1a3-py3-none-any.whl", "has_sig": false, "md5_digest": "71abf66b655c3e572bd5773711dff691", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11429, "upload_time": "2019-01-31T14:32:56", "url": "https://files.pythonhosted.org/packages/32/2a/8a2c298005a211dad3c679518ff23855756b2caa1db3f64a4de1b389df65/color_extraction-0.1a3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aa7b197263d7c765279e76ecd75927c3", "sha256": "30ea7902783079ea7d7a8e4125d03e45cf76d2e113d4873ab1d8d8c297db3212" }, "downloads": -1, "filename": "color_extraction-0.1a3.tar.gz", "has_sig": false, "md5_digest": "aa7b197263d7c765279e76ecd75927c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7827, "upload_time": "2019-01-31T14:33:11", "url": "https://files.pythonhosted.org/packages/8c/b2/2f022333f238f8b9348fe7bac1f1b88901a6383a934e0390fbb188e4f7f6/color_extraction-0.1a3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "71abf66b655c3e572bd5773711dff691", "sha256": "39c143d3c22c3fbe4208957abf1dc7056600d5be4a56aec719579de0e471c206" }, "downloads": -1, "filename": "color_extraction-0.1a3-py3-none-any.whl", "has_sig": false, "md5_digest": "71abf66b655c3e572bd5773711dff691", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11429, "upload_time": "2019-01-31T14:32:56", "url": "https://files.pythonhosted.org/packages/32/2a/8a2c298005a211dad3c679518ff23855756b2caa1db3f64a4de1b389df65/color_extraction-0.1a3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aa7b197263d7c765279e76ecd75927c3", "sha256": "30ea7902783079ea7d7a8e4125d03e45cf76d2e113d4873ab1d8d8c297db3212" }, "downloads": -1, "filename": "color_extraction-0.1a3.tar.gz", "has_sig": false, "md5_digest": "aa7b197263d7c765279e76ecd75927c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7827, "upload_time": "2019-01-31T14:33:11", "url": "https://files.pythonhosted.org/packages/8c/b2/2f022333f238f8b9348fe7bac1f1b88901a6383a934e0390fbb188e4f7f6/color_extraction-0.1a3.tar.gz" } ] }