Skip to main content

some stuff for images

Tested against Windows 10 / Python 3.11 / Anaconda

pip install cythonimagever

Cython and a C compiler must be installed!

import numpy as np
import cv2
from cythonimagever import all_colors_in,any_colors_in,average_rgb,find_colors,rgb_color_count_numpy,rgb_color_count_sorted_by_qty_numpy,rgb_color_count_sorted_by_color_numpy
from a_cv_imwrite_imread_plus import open_image_in_cv
from time import perf_counter
# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/
picpath = r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg"
picture = open_image_in_cv(picpath, channels_in_output=3)
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),
        (10, 15, 122),
    ],
    dtype=np.uint8,
)
print(f'{rgb_color_count_numpy(picture, picture.shape) =}')
print(f'{rgb_color_count_sorted_by_qty_numpy(picture, picture.shape) =}')
print(f'{rgb_color_count_sorted_by_color_numpy(picture, picture.shape) =}')
print(f'{find_colors(picture, colors1) =}')
print(f'{average_rgb(picture) =}')
print(f'{any_colors_in(picture, colors1) =}')
print(f'{all_colors_in(picture, colors1) =}')

# rgb_color_count_numpy(picture, picture.shape) =array([[   0,    0,    0,   38],
#        [   1,    0,    0,   33],
#        [   3,    0,    0,   41],
#        ...,
#        [ 252,  255,  255,  183],
#        [ 254,  255,  255, 1495],
#        [ 255,  255,  255, 4588]], dtype=uint32)
# rgb_color_count_sorted_by_qty_numpy(picture, picture.shape) =array([[   132,     83,     76,      1],
#        [   184,     71,     31,      1],
#        [   189,     71,     31,      1],
#        ...,
#        [    12,     21,     26, 417740],
#        [    13,     22,     27, 418847],
#        [    11,     20,     25, 447605]], dtype=uint32)
# rgb_color_count_sorted_by_color_numpy(picture, picture.shape) =array([[   0,    0,    0,   38],
#        [   1,    0,    0,   33],
#        [   3,    0,    0,   41],
#        ...,
#        [ 252,  255,  255,  183],
#        [ 254,  255,  255, 1495],
#        [ 255,  255,  255, 4588]], dtype=uint32)
# find_colors(picture, colors1) =array([[ 127,  138,  136,   38,    0],
#        [  66,   71,   69, 4522,    0],
#        [  62,   67,   65, 4523,    0],
#        ...,
#        [  24,   17,    8, 4522, 6622],
#        [  24,   17,    8, 4523, 6622],
#        [  24,   17,    8, 4524, 6622]], dtype=int64)
# average_rgb(picture) =(76, 83, 85)
# any_colors_in(picture, colors1) =True
# all_colors_in(picture, colors1) =array([[ 66,  71,  69,   1],
#        [ 62,  67,  65,   1],
#        [144, 155, 153,   1],
#        [ 52,  57,  55,   1],
#        [127, 138, 136,   1],
#        [ 53,  58,  56,   1],
#        [ 51,  56,  54,   1],
#        [ 32,  27,  18,   1],
#        [ 24,  17,   8,   1],
#        [ 10,  15, 122,   0]], dtype=uint8)

Metadata

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

Built distribution (wheel)

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

Total release size: 49.1 kB

Release files / cythonimagever-0.10.tar.gz

Download URL cythonimagever-0.10.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bb130e73187b9d15de8cf91e899cf4b970ad346fc9ae58b59ea06831bbedca1c
BLAKE2b-256 checksum
How to use checksums
6c6a3a16ed5a488fa35c5d846343a01853a342c0b901e7f1f815f282c5ef18a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

Download URL cythonimagever-0.10-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a8d61472f77ba45e4fe357153af06d661aa6fff0876352da2215d1f30005347
BLAKE2b-256 checksum
How to use checksums
bbd764c72b130fc16080a4a121f59bcb06080cdd6d3e96291a0a40c60ed05d7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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