Skip to main content

RGBA color search with Cython

pip install cythonrgbasearch

Tested against Windows / Python 3.11 / Anaconda

Cython (and a C/C++ compiler) must be installed

from cythonrgbasearch import find_rgba_colors, find_rgb_colors
import cv2
import numpy as np

data = cv2.imread(r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg")
# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/
data = np.ascontiguousarray(np.dstack([data, np.full(data.shape[:2], 0, dtype=np.uint8)]))
colors1 = np.array(
    [(66, 71, 69), (62, 67, 65), (144, 155, 153), (52, 57, 55), (127, 138, 136), (53, 58, 56), (51, 56, 54),
     (32, 27, 18), (24, 17, 8), ], dtype=np.uint8)
colors1 = np.array([list((x.tolist())) + [0] for x in colors1], dtype=np.uint8)
ocol = np.array([[255, 255, 255, 0]], dtype=np.uint8)
r1 = find_rgba_colors(pic=data, colors=colors1, dummy_alpha=0)
r2 = find_rgba_colors(pic=data, colors=ocol, dummy_alpha=0)
r3 = find_rgb_colors(pic=data, colors=colors1)
r4 = find_rgb_colors(pic=data, colors=ocol)

# r1
# Out[4]:
# rec.array([(136, 138, 127, 0,    0,   38), ( 69,  71,  66, 0,    0, 4522),
#            ( 65,  67,  62, 0,    0, 4523), ...,
#            (  8,  17,  24, 0, 4524, 6620), (  8,  17,  24, 0, 4524, 6621),
#            (  8,  17,  24, 0, 4524, 6622)],
#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('a', 'u1'), ('x', '<i8'), ('y', '<i8')])
# r2
# Out[5]:
# rec.array([(255, 255, 255, 0,  568, 5021), (255, 255, 255, 0,  586, 3064),
#            (255, 255, 255, 0,  612, 2812), ...,
#            (255, 255, 255, 0, 3752,  805), (255, 255, 255, 0, 3752,  806),
#            (255, 255, 255, 0, 3775, 1291)],
#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('a', 'u1'), ('x', '<i8'), ('y', '<i8')])
# r3
# Out[6]:
# rec.array([(136, 138, 127,    0,   38), ( 69,  71,  66,    0, 4522),
#            ( 65,  67,  62,    0, 4523), ..., (  8,  17,  24, 4524, 6620),
#            (  8,  17,  24, 4524, 6621), (  8,  17,  24, 4524, 6622)],
#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('x', '<i8'), ('y', '<i8')])
# r4
# Out[7]:
# rec.array([(255, 255, 255,  568, 5021), (255, 255, 255,  586, 3064),
#            (255, 255, 255,  612, 2812), ..., (255, 255, 255, 3752,  805),
#            (255, 255, 255, 3752,  806), (255, 255, 255, 3775, 1291)],
#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('x', '<i8'), ('y', '<i8')])

Metadata

Release files for cythonrgbasearch 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 cythonrgbasearch 0.10
File Size Uploaded Provenance Actions
cythonrgbasearch-0.10.tar.gz 22.4 kB Without provenance Details for cythonrgbasearch-0.10.tar.gz

Built distribution (wheel)

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

Total release size: 44.9 kB

Release files / cythonrgbasearch-0.10.tar.gz

Download URL cythonrgbasearch-0.10.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6d42f4901d720763417bf31287834a938d00a77d5e856abf0b329c636cdb9b32
BLAKE2b-256 checksum
How to use checksums
4caa43a49810f3c0ff5c66284c58684c0dfd32f627c9d6916a3325e5c2f30a07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

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

Download URL cythonrgbasearch-0.10-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec345cd5d500d17a6df8cea4cedb89028b46152b114a8bbd779d9dac4c0bf374
BLAKE2b-256 checksum
How to use checksums
013e3d8c700ab9de17eee32c4b80d541bc271d23362265f893108e0a0bf1e308
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for cythonrgbasearch 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