<div align="center">
<h1> ImageDominantColor </h1>
<h4>Get the dominant color of any image</h4>
</div>
<p align="center">
<a href="https://github.com/akamhy/imagedominantcolor/actions?query=workflow%3ATest"><img alt="Build Status" src="https://github.com/akamhy/imagedominantcolor/workflows/Test/badge.svg"></a>
<a href="https://codecov.io/gh/akamhy/imagedominantcolor"><img alt="codecov" src="https://codecov.io/gh/akamhy/imagedominantcolor/branch/main/graph/badge.svg?token=xCV7vQ9MJo"></a>
<a href="https://pypi.org/project/imagedominantcolor/"><img alt="pypi" src="https://img.shields.io/pypi/v/imagedominantcolor.svg"></a>
<a href="https://pepy.tech/project/imagedominantcolor?versions=1*"><img alt="Downloads" src="https://pepy.tech/badge/imagedominantcolor/month"></a>
<a href="#"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/imagedominantcolor?style=flat-square"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>
### Introduction
ImageDominantColor is a Python package/library for **detecting dominant color of images**.
It can take any input image and tell the dominant color in image. It does not uses k-means clustering for detecting dominant color but instead quantize the individual pixels and calculates the statistical mode of the quantized values. And yes, it works!
ImageDominantColor does not depend on numpy unlike most of the other implementations for the same task and is also fast and minimalist.
What ImageDominantColor is not?
> ImageDominantColor does not calculates the average color of the image. Also note that the average color of an image is not same as its dominant color.
### Installation
- Using [pip](https://en.wikipedia.org/wiki/Pip_(package_manager)):
```bash
pip install imagedominantcolor -U
```
- Install directly from GitHub:
```bash
pip install git+https://github.com/akamhy/imagedominantcolor.git
```
### Usage
```python
>>> from imagedominantcolor import DominantColor
>>> file_path = "blue_butterfly.jpg" # Blue color is dominant
>>> dominantcolor = DominantColor(file_path)
>>> dominantcolor.dominant_color
'b'
>>> dominantcolor.rgb
(3, 6, 244)
>>> dir(dominantcolor)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'b', 'counter', 'dominant_color', 'dominant_color_of_pixel', 'dominant_color_of_pixels_of_image_array', 'g', 'generate_dominant_color_of_pixels_of_image_array', 'image', 'image_data', 'image_path', 'l', 'minimum_percent_difference_of_rgb', 'mpd', 'r', 'resize_value', 'resized_image', 'rgb', 'rgbl', 'set_dominat_color_of_image', 'set_rgbl_value_of_image', 'total_pixels']
>>> dominantcolor.total_pixels
256
>>> dominantcolor.r
3
>>> dominantcolor.g
6
>>> dominantcolor.b
244
>>> dominantcolor.l
3
>>> dominantcolor.rgbl
(3, 6, 244, 3)
>>> repr(dominantcolor)
'DominantColor(r:3 g:6 b:244 l:3; dominant_color:b; resize_value:16; minimum_percent_difference_of_rgb:10)'
>>> str(dominantcolor)
'b'
>>>
```
Output dominant color and what their meanings are:
- `r` - Red is the dominant color in the image.
- `g` - Green is the dominant color for the image.
- `b` - Blue is the dominant color.
- `l` - It is lowercase L and it implies that the image is a mostly a grayscale image. L for luminance and most of the image lacks color.
- `n` - None of the color out of r, g and b are dominant but the image is not grayscale. It implies that the image has equal regions where 2 or 3 colors dominate, [example here](https://user-images.githubusercontent.com/64683866/151845374-dd1a83e5-3265-491e-830d-39be120af65b.png). You can check the rgb attribute to decide what to do with such cases.
What are `r`, `g`, `b` and `l` attributes of `DominantColor` objects?
> The library shrinks the image before checking the dominant color and the default resize value is 256. Thus every image is shrunk to a 256 pixels image.
The r,g,b and l attributes indicate the number of pixels which have r,g,b and l as dominating value.
### License
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/akamhy/imagedominantcolor/blob/main/LICENSE)
Copyright (c) 2022 Akash Mahanty.
Released under the MIT License. See
[license](https://github.com/akamhy/imagedominantcolor/blob/main/LICENSE) for details.
Raw data
{
"_id": null,
"home_page": "https://akamhy.github.io/imagedominantcolor/",
"name": "imagedominantcolor",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "Get dominant colors of image,imagedominantcolor,Extract dominant colors of an image using Python,Dominant colors,most prevalent color,most dominant colors",
"author": "Akash Mahanty",
"author_email": "akamhy@yahoo.com",
"download_url": "https://files.pythonhosted.org/packages/fe/3e/504aa527e9a3eb287a5d0d382fcff9b2580af91b45a9fe21dff95be96651/imagedominantcolor-1.0.1.tar.gz",
"platform": "",
"description": "<div align=\"center\">\n<h1> ImageDominantColor </h1>\n<h4>Get the dominant color of any image</h4>\n</div>\n\n<p align=\"center\">\n<a href=\"https://github.com/akamhy/imagedominantcolor/actions?query=workflow%3ATest\"><img alt=\"Build Status\" src=\"https://github.com/akamhy/imagedominantcolor/workflows/Test/badge.svg\"></a>\n<a href=\"https://codecov.io/gh/akamhy/imagedominantcolor\"><img alt=\"codecov\" src=\"https://codecov.io/gh/akamhy/imagedominantcolor/branch/main/graph/badge.svg?token=xCV7vQ9MJo\"></a>\n<a href=\"https://pypi.org/project/imagedominantcolor/\"><img alt=\"pypi\" src=\"https://img.shields.io/pypi/v/imagedominantcolor.svg\"></a>\n<a href=\"https://pepy.tech/project/imagedominantcolor?versions=1*\"><img alt=\"Downloads\" src=\"https://pepy.tech/badge/imagedominantcolor/month\"></a>\n<a href=\"#\"><img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/imagedominantcolor?style=flat-square\"></a>\n<a href=\"https://github.com/psf/black\"><img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"></a>\n</p>\n\n### Introduction\nImageDominantColor is a Python package/library for **detecting dominant color of images**.\n\nIt can take any input image and tell the dominant color in image. It does not uses k-means clustering for detecting dominant color but instead quantize the individual pixels and calculates the statistical mode of the quantized values. And yes, it works!\n\nImageDominantColor does not depend on numpy unlike most of the other implementations for the same task and is also fast and minimalist.\n\n\nWhat ImageDominantColor is not?\n> ImageDominantColor does not calculates the average color of the image. Also note that the average color of an image is not same as its dominant color.\n\n\n### Installation\n\n - Using [pip](https://en.wikipedia.org/wiki/Pip_(package_manager)):\n\n```bash\npip install imagedominantcolor -U\n```\n\n - Install directly from GitHub:\n\n```bash\npip install git+https://github.com/akamhy/imagedominantcolor.git\n```\n\n\n### Usage\n```python\n>>> from imagedominantcolor import DominantColor\n>>> file_path = \"blue_butterfly.jpg\" # Blue color is dominant\n>>> dominantcolor = DominantColor(file_path)\n>>> dominantcolor.dominant_color\n'b'\n>>> dominantcolor.rgb\n(3, 6, 244)\n>>> dir(dominantcolor)\n['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'b', 'counter', 'dominant_color', 'dominant_color_of_pixel', 'dominant_color_of_pixels_of_image_array', 'g', 'generate_dominant_color_of_pixels_of_image_array', 'image', 'image_data', 'image_path', 'l', 'minimum_percent_difference_of_rgb', 'mpd', 'r', 'resize_value', 'resized_image', 'rgb', 'rgbl', 'set_dominat_color_of_image', 'set_rgbl_value_of_image', 'total_pixels']\n>>> dominantcolor.total_pixels\n256\n>>> dominantcolor.r\n3\n>>> dominantcolor.g\n6\n>>> dominantcolor.b\n244\n>>> dominantcolor.l\n3\n>>> dominantcolor.rgbl\n(3, 6, 244, 3)\n>>> repr(dominantcolor)\n'DominantColor(r:3 g:6 b:244 l:3; dominant_color:b; resize_value:16; minimum_percent_difference_of_rgb:10)'\n>>> str(dominantcolor)\n'b'\n>>>\n```\n\nOutput dominant color and what their meanings are:\n\n - `r` - Red is the dominant color in the image.\n - `g` - Green is the dominant color for the image.\n - `b` - Blue is the dominant color.\n - `l` - It is lowercase L and it implies that the image is a mostly a grayscale image. L for luminance and most of the image lacks color.\n - `n` - None of the color out of r, g and b are dominant but the image is not grayscale. It implies that the image has equal regions where 2 or 3 colors dominate, [example here](https://user-images.githubusercontent.com/64683866/151845374-dd1a83e5-3265-491e-830d-39be120af65b.png). You can check the rgb attribute to decide what to do with such cases.\n\nWhat are `r`, `g`, `b` and `l` attributes of `DominantColor` objects?\n> The library shrinks the image before checking the dominant color and the default resize value is 256. Thus every image is shrunk to a 256 pixels image.\nThe r,g,b and l attributes indicate the number of pixels which have r,g,b and l as dominating value.\n\n### License\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/akamhy/imagedominantcolor/blob/main/LICENSE)\n\nCopyright (c) 2022 Akash Mahanty.\n\nReleased under the MIT License. See\n[license](https://github.com/akamhy/imagedominantcolor/blob/main/LICENSE) for details.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Find dominant aka most common color of any image.",
"version": "1.0.1",
"project_urls": {
"Download": "https://github.com/akamhy/imagedominantcolor/archive/1.0.1.tar.gz",
"Homepage": "https://akamhy.github.io/imagedominantcolor/",
"Source": "https://github.com/akamhy/imagedominantcolor",
"Tracker": "https://github.com/akamhy/imagedominantcolor/issues"
},
"split_keywords": [
"get dominant colors of image",
"imagedominantcolor",
"extract dominant colors of an image using python",
"dominant colors",
"most prevalent color",
"most dominant colors"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8ccf92931dbe2151fc92db9827dd12da43fc97e6579e3658e847f10e2f5bce67",
"md5": "2bef7a9548b100a750461a0b36381dc4",
"sha256": "d890d61f78637f718f5eb6afbd60919317b889c45c5c4133d6bf8e670b18ff6c"
},
"downloads": -1,
"filename": "imagedominantcolor-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2bef7a9548b100a750461a0b36381dc4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5925,
"upload_time": "2022-01-31T18:38:03",
"upload_time_iso_8601": "2022-01-31T18:38:03.560106Z",
"url": "https://files.pythonhosted.org/packages/8c/cf/92931dbe2151fc92db9827dd12da43fc97e6579e3658e847f10e2f5bce67/imagedominantcolor-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fe3e504aa527e9a3eb287a5d0d382fcff9b2580af91b45a9fe21dff95be96651",
"md5": "12a029974097a11d8603818cc2e69318",
"sha256": "f37790dfb52402a636231e8e0a1148f241990d4ff75f6b6e7f838885ffef7079"
},
"downloads": -1,
"filename": "imagedominantcolor-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "12a029974097a11d8603818cc2e69318",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5375,
"upload_time": "2022-01-31T18:38:05",
"upload_time_iso_8601": "2022-01-31T18:38:05.098114Z",
"url": "https://files.pythonhosted.org/packages/fe/3e/504aa527e9a3eb287a5d0d382fcff9b2580af91b45a9fe21dff95be96651/imagedominantcolor-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-01-31 18:38:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "akamhy",
"github_project": "imagedominantcolor",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "imagedominantcolor"
}