Skip to main content

This module provides functionality to count unique colors in an image represented as a NumPy array and, optionally, group their coordinates. It includes a Cython-based implementation for improved performance.

Project description

This module provides functionality to count unique colors in an image represented as a NumPy array and, optionally, group their coordinates.

Tested against Windows / Python 3.11 / Anaconda

pip install colorcountcython

This module provides functionality to count unique colors in an image represented as a NumPy array and, optionally, group their coordinates. It includes a Cython-based implementation for improved performance.

Functions:
- colorcount(pic, coords=True, count=True):
  Count the unique colors in an image represented as a NumPy array. If `coords` is set to True, it also groups the coordinates of each color.

Internal Functions:
- _dummyimport():
  Internal function to check the availability of Cython.
- searchallcolors(pic, totallengthpic, width, withcoords, withcount):
  Cython function to count colors in an image and, if specified, group their coordinates.

Parameters:
- pic (ndarray): The input image represented as a NumPy array.
- coords (bool): If True, the function will return the coordinates of each unique color.
- count (bool): If True, the function will return the count of each unique color.

Returns:
A dictionary containing unique color information. If `coords` is True, it includes the coordinates of each color. If `count` is True, it includes the count of each color.

Note:
The `colorcount` function takes an image as input and returns a dictionary containing color counts and, if specified, color coordinates. The Cython-based implementation in this module enhances the performance of color counting.

Example:
	from a_cv_imwrite_imread_plus import open_image_in_cv
	from colorcountcython import colorcount
	b=open_image_in_cv('c:\\tetetete.png')
	d=colorcount(pic=b,coords=True, count=True)
	print(d)

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

colorcountcython-0.10.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

colorcountcython-0.10-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for colorcountcython-0.10.tar.gz
Algorithm Hash digest
SHA256 f949e98ba171869166f6ee7126f274137770b134d5d70e41a1e9f4fdcc81a990
MD5 be86a69a3697379d9f56279b7cef7a5b
BLAKE2b-256 7800fa6d9d7fbbd24c3a935d36a7d8c65dd395777c4ce9413316498e139007a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for colorcountcython-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f8dcbf1c76bf83210995d40bdb709147e3246bd6a3094790b824eb69eaf8902c
MD5 dfc9482f4bf2c29d79a603c12a055f39
BLAKE2b-256 251e6fa7a1dedf510f4bebdb120a82bbd75a6edb832333765a4d8f263a56eb4b

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