Skip to main content

some stuff for images

Project description

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)

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

cythonimagever-0.10.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

cythonimagever-0.10-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cythonimagever-0.10.tar.gz
Algorithm Hash digest
SHA256 bb130e73187b9d15de8cf91e899cf4b970ad346fc9ae58b59ea06831bbedca1c
MD5 45911701c000f018712f16544190e0b2
BLAKE2b-256 6c6a3a16ed5a488fa35c5d846343a01853a342c0b901e7f1f815f282c5ef18a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cythonimagever-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8d61472f77ba45e4fe357153af06d661aa6fff0876352da2215d1f30005347
MD5 78a2dd1ea2bde4e48802b8b85e4532b7
BLAKE2b-256 bbd764c72b130fc16080a4a121f59bcb06080cdd6d3e96291a0a40c60ed05d7c

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