cythonrgbasearch


Namecythonrgbasearch JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/cythonrgbasearch
SummaryRGBA color search with Cython
upload_time2023-12-08 07:10:51
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords cython rgba
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# RGBA color search with Cython

## pip install cythonrgbasearch

### Tested against Windows / Python 3.11 / Anaconda


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



```python
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')])


```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/cythonrgbasearch",
    "name": "cythonrgbasearch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "cython,RGBA",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/aa/43a49810f3c0ff5c66284c58684c0dfd32f627c9d6916a3325e5c2f30a07/cythonrgbasearch-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# RGBA color search with Cython\r\n\r\n## pip install cythonrgbasearch\r\n\r\n### Tested against Windows / Python 3.11 / Anaconda\r\n\r\n\r\n## Cython (and a C/C++ compiler) must be installed\r\n\r\n\r\n\r\n```python\r\nfrom cythonrgbasearch import find_rgba_colors, find_rgb_colors\r\nimport cv2\r\nimport numpy as np\r\n\r\ndata = cv2.imread(r\"C:\\Users\\hansc\\Downloads\\pexels-alex-andrews-2295744.jpg\")\r\n# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/\r\ndata = np.ascontiguousarray(np.dstack([data, np.full(data.shape[:2], 0, dtype=np.uint8)]))\r\ncolors1 = np.array(\r\n    [(66, 71, 69), (62, 67, 65), (144, 155, 153), (52, 57, 55), (127, 138, 136), (53, 58, 56), (51, 56, 54),\r\n     (32, 27, 18), (24, 17, 8), ], dtype=np.uint8)\r\ncolors1 = np.array([list((x.tolist())) + [0] for x in colors1], dtype=np.uint8)\r\nocol = np.array([[255, 255, 255, 0]], dtype=np.uint8)\r\nr1 = find_rgba_colors(pic=data, colors=colors1, dummy_alpha=0)\r\nr2 = find_rgba_colors(pic=data, colors=ocol, dummy_alpha=0)\r\nr3 = find_rgb_colors(pic=data, colors=colors1)\r\nr4 = find_rgb_colors(pic=data, colors=ocol)\r\n\r\n# r1\r\n# Out[4]:\r\n# rec.array([(136, 138, 127, 0,    0,   38), ( 69,  71,  66, 0,    0, 4522),\r\n#            ( 65,  67,  62, 0,    0, 4523), ...,\r\n#            (  8,  17,  24, 0, 4524, 6620), (  8,  17,  24, 0, 4524, 6621),\r\n#            (  8,  17,  24, 0, 4524, 6622)],\r\n#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('a', 'u1'), ('x', '<i8'), ('y', '<i8')])\r\n# r2\r\n# Out[5]:\r\n# rec.array([(255, 255, 255, 0,  568, 5021), (255, 255, 255, 0,  586, 3064),\r\n#            (255, 255, 255, 0,  612, 2812), ...,\r\n#            (255, 255, 255, 0, 3752,  805), (255, 255, 255, 0, 3752,  806),\r\n#            (255, 255, 255, 0, 3775, 1291)],\r\n#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('a', 'u1'), ('x', '<i8'), ('y', '<i8')])\r\n# r3\r\n# Out[6]:\r\n# rec.array([(136, 138, 127,    0,   38), ( 69,  71,  66,    0, 4522),\r\n#            ( 65,  67,  62,    0, 4523), ..., (  8,  17,  24, 4524, 6620),\r\n#            (  8,  17,  24, 4524, 6621), (  8,  17,  24, 4524, 6622)],\r\n#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('x', '<i8'), ('y', '<i8')])\r\n# r4\r\n# Out[7]:\r\n# rec.array([(255, 255, 255,  568, 5021), (255, 255, 255,  586, 3064),\r\n#            (255, 255, 255,  612, 2812), ..., (255, 255, 255, 3752,  805),\r\n#            (255, 255, 255, 3752,  806), (255, 255, 255, 3775, 1291)],\r\n#           dtype=[('r', 'u1'), ('g', 'u1'), ('b', 'u1'), ('x', '<i8'), ('y', '<i8')])\r\n\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "RGBA color search with Cython",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/cythonrgbasearch"
    },
    "split_keywords": [
        "cython",
        "rgba"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "013e3d8c700ab9de17eee32c4b80d541bc271d23362265f893108e0a0bf1e308",
                "md5": "aef6b6d2f7b781fbebaeded7de7050ee",
                "sha256": "ec345cd5d500d17a6df8cea4cedb89028b46152b114a8bbd779d9dac4c0bf374"
            },
            "downloads": -1,
            "filename": "cythonrgbasearch-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aef6b6d2f7b781fbebaeded7de7050ee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22543,
            "upload_time": "2023-12-08T07:10:49",
            "upload_time_iso_8601": "2023-12-08T07:10:49.255923Z",
            "url": "https://files.pythonhosted.org/packages/01/3e/3d8c700ab9de17eee32c4b80d541bc271d23362265f893108e0a0bf1e308/cythonrgbasearch-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4caa43a49810f3c0ff5c66284c58684c0dfd32f627c9d6916a3325e5c2f30a07",
                "md5": "105636c5340903f693e2df5644713cc8",
                "sha256": "6d42f4901d720763417bf31287834a938d00a77d5e856abf0b329c636cdb9b32"
            },
            "downloads": -1,
            "filename": "cythonrgbasearch-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "105636c5340903f693e2df5644713cc8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22395,
            "upload_time": "2023-12-08T07:10:51",
            "upload_time_iso_8601": "2023-12-08T07:10:51.403462Z",
            "url": "https://files.pythonhosted.org/packages/4c/aa/43a49810f3c0ff5c66284c58684c0dfd32f627c9d6916a3325e5c2f30a07/cythonrgbasearch-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-08 07:10:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "cythonrgbasearch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cythonrgbasearch"
}
        
Elapsed time: 0.18855s