Skip to main content

Counts the unique colors in an image and returns a DataFrame with color counts and optional color coordinates.

Project description

Counts the unique colors in an image and returns a DataFrame with color counts and optional color coordinates.

Tested against Windows 10 / Python 3.11 / Anaconda

pip install farbencounter

# Example usage
from farbencounter import count_colors
pic = r"https://www.python.org/static/img/python-logo.png"
img = open_image_in_cv(pic, channels_in_output=3)
df, colorcoords = count_colors(img=img, sort=True, get_color_coords=True)

# df: DataFrame containing color information and counts
# colorcoords: Dictionary containing color coordinates


# df
# Out[3]:
#             a    r    g    b      c
# 0           0    0    0    0    456
# 1          26    0    0   26      2
# 2        3612    0   14   28      2
# 3        3619    0   14   35      1
# 4        3870    0   15   30      9
# ..        ...  ...  ...  ...    ...
# 849  16776316  255  252  124      2
# 850  16776431  255  252  239      1
# 851  16776432  255  252  240      1
# 852  16776830  255  254  126      1
# 853  16777215  255  255  255  18608
# [854 rows x 5 columns]


# colorcoords
# ....
# (44, 99, 147): array([[48, 32]]),
#  (45,
#   45,
#   45): array([[230,  28],
#         [170,  32],
#         [189,  52]], dtype=int64),
#  (45, 86, 119): array([[12, 25]]),
#  (45, 94, 133): array([[ 8, 30]]),
#  (45, 96, 139): array([[20, 43]]),
#  (45, 101, 150): array([[45, 36]]),
#  (46, 35, 12): array([[36, 53]]),
#  (46,
#   46,
#   46): array([[239,  14],
#         [143,  23],
#         [143,  28],
#         [170,  34],
#         [185,  34],
#         [ 84,  45],
#         [ 90,  48],
#         [118,  48],
#         [119,  48],
#         [201,  48],
#         [194,  52]], dtype=int64)
# ....

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

farbencounter-0.10.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

farbencounter-0.10-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file farbencounter-0.10.tar.gz.

File metadata

  • Download URL: farbencounter-0.10.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for farbencounter-0.10.tar.gz
Algorithm Hash digest
SHA256 b98a9fb70b3fae5f8c747253be6c1279eadf102d70a09d2038a25ad2013d5aa9
MD5 523594570593d19d6a2e30871d78c1fe
BLAKE2b-256 4039bbac518c8f75f70c973115816dc09ab2a83867ee015c4b905fa4d412a6de

See more details on using hashes here.

File details

Details for the file farbencounter-0.10-py3-none-any.whl.

File metadata

  • Download URL: farbencounter-0.10-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for farbencounter-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 4b7771e2964a378ff065d1a89d1ffa7a23de493ea526c833a2a28617a58ba8af
MD5 d30e40b1379089709a01bab8dc01d8b6
BLAKE2b-256 8ea8d636a585807d9d5f40c9657e760702ac606d297942d857ba17a01b55fed3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page