Skip to main content

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)

Metadata

Release files for getdominantcolor 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for getdominantcolor 0.10
File Size Uploaded Provenance Actions
getdominantcolor-0.10.tar.gz 20.1 kB Without provenance Details for getdominantcolor-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for getdominantcolor 0.10
File Interpreter ABI Platform Actions
getdominantcolor-0.10-py3-none-any.whl Python 3 none any Details for getdominantcolor-0.10-py3-none-any.whl

Total release size: 40.9 kB

Release files / getdominantcolor-0.10.tar.gz

Download URL getdominantcolor-0.10.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
65730cfd12812fb34f36f13d78394e046b4b4a55828837e013549cc7ec20d71d
BLAKE2b-256 checksum
How to use checksums
35ff6e35ec7850684b758e4468b817e95924f10689d7d6c61d72c127021e4e7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / getdominantcolor-0.10-py3-none-any.whl

Download URL getdominantcolor-0.10-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
274b3283c80f239ba1d7954dc40eae36f8684e32a9a61bceb658a9d9a0139315
BLAKE2b-256 checksum
How to use checksums
8c4b3b9d65b9894426d4889733061d77b45ddd7a4de862afe5f61ee291ad38b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for getdominantcolor 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page