Extracts the dominant color from an image represented by an array.
Project description
Extracts the dominant color from an image represented by an array.
pip install getdominantcolor
Tested against Windows / Python 3.11 / Anaconda
Parameters:
- x (numpy.ndarray): The input image represented as a NumPy array with shape (height, width, channels - 3).
Returns:
tuple: A tuple representing the dominant color in the RGB format (red, green, blue).
The function reshapes the input array to a two-dimensional array and calculates a numerical code for each pixel
based on its RGB values. The dominant color is then determined by counting the occurrences of these codes and
returning the RGB values of the code with the highest frequency.
Example:
from getdominantcolor import get_dom_color
import numpy as np
np.random.seed(0)
x = np.random.randint(0, 255, (4000, 4000, 3))
get_dom_color(x)
# (81, 101, 238)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
getdominantcolor-0.10.tar.gz
(20.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file getdominantcolor-0.10.tar.gz.
File metadata
- Download URL: getdominantcolor-0.10.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65730cfd12812fb34f36f13d78394e046b4b4a55828837e013549cc7ec20d71d
|
|
| MD5 |
f14bddb12d2598b7c0e4ee1403ad3225
|
|
| BLAKE2b-256 |
35ff6e35ec7850684b758e4468b817e95924f10689d7d6c61d72c127021e4e7e
|
File details
Details for the file getdominantcolor-0.10-py3-none-any.whl.
File metadata
- Download URL: getdominantcolor-0.10-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
274b3283c80f239ba1d7954dc40eae36f8684e32a9a61bceb658a9d9a0139315
|
|
| MD5 |
d6e8e71f6392c6233c812c6d338bc28e
|
|
| BLAKE2b-256 |
8c4b3b9d65b9894426d4889733061d77b45ddd7a4de862afe5f61ee291ad38b7
|