cythonimagetools


Namecythonimagetools JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/cythonimagetools
SummaryProvides functions (Cython - C) for color analysis in images, including finding unique colors, counting occurrences, and comparing images
upload_time2023-12-01 10:03:24
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords rgb cython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Provides functions (Cython - C) for color analysis in images, including finding unique colors, counting occurrences, and comparing images

## pip install cythonimagetools

### Tested against Windows / Python 3.11 / Anaconda

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


```python
import numpy as np
from cythonimagetools import get_unique_colors, count_colors, get_most_frequent_colors, get_rgb_coords, \
    get_rgb_coords_parallel, compare_rgb_values_of_2_pics, find_color_ranges

# Generate a random image
np.random.seed(0)
x = np.random.randint(0, 9, (1000, 1000, 3))

# Get unique colors in the image
uniquecolors = get_unique_colors(x)
print(uniquecolors)

# Count the occurrence of each color in the image
allcolors = count_colors(x)
print(allcolors)

# Get the most frequent colors in the image
most_freq_colors = get_most_frequent_colors(x)
print(most_freq_colors)

# Get RGB coordinates of each pixel in the image
rgb_coords = get_rgb_coords(x)
print(rgb_coords)

# Get RGB coordinates in parallel
rgb_coords_parallel = get_rgb_coords_parallel(x)
print(rgb_coords_parallel)

# Compare RGB values of two images within a specified tolerance
pic1 = np.random.randint(0, 255, (1000, 1000, 3), dtype=np.uint8)
pic2 = np.random.randint(0, 200, (1000, 1000, 3), dtype=np.uint8)
ru = compare_rgb_values_of_2_pics(pic1, pic2, rmax=10, gmax=10, bmax=10)
print(ru)

# Find color ranges in an image based on given colors and tolerance
colors = np.array([[2, 7, 4], [4, 7, 2]], dtype=np.uint8)
foundcolors = find_color_ranges(x, colors, rmax=1, gmax=1, bmax=2)
print(foundcolors)


print(uniquecolors)
print('--------------------')

print(allcolors)
print('--------------------')

print(most_freq_colors)
print('--------------------')

print(rgb_coords)
print('--------------------')

print(rgb_coords_parallel)
print('--------------------')

print(ru)
print('--------------------')

print(colors)
print('--------------------')

print(foundcolors)
print('--------------------')


# [[3 0 5]
#  [3 7 3]
#  [4 2 5]
#  ...
#  [2 0 7]
#  [3 8 5]
#  [2 4 1]]
# --------------------
# [[   3    0    5 1402]
#  [   3    7    3 1380]
#  [   4    2    5 1369]
#  ...
#  [   2    0    7 1413]
#  [   3    8    5 1343]
#  [   2    4    1 1405]]
# --------------------
# [[   2    7    4 1473]]
# --------------------
# [[  3   0   5   0   0]
#  [  3   7   3   0   1]
#  [  4   2   5   0   2]
#  ...
#  [  6   1   1 999 997]
#  [  0   6   4 999 998]
#  [  8   0   6 999 999]]
# --------------------
# [[  3   0   5   0   0]
#  [  3   7   3   0   1]
#  [  4   2   5   0   2]
#  ...
#  [  6   1   1 999 997]
#  [  0   6   4 999 998]
#  [  8   0   6 999 999]]
# --------------------
# [[143  76  62 ...   5 920   0]
#  [153  80  38 ...   9 190   3]
#  [ 42 198  93 ...   8 332   3]
#  ...
#  [ 71  12  64 ...   5   0 995]
#  [174  85 160 ...   7 107 996]
#  [193  37 160 ...   0 817 997]]
# --------------------
# [[2 7 4]
#  [4 7 2]]
# --------------------
# [[  4   7   2 ...   1   0   1]
#  [  4   7   2 ...   2   0  22]
#  [  4   7   2 ...   2   0  24]
#  ...
#  [  4   7   2 ...   2 999 956]
#  [  4   7   2 ...   2 999 970]
#  [  2   7   4 ...   0 999 987]]
# --------------------
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/cythonimagetools",
    "name": "cythonimagetools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "rgb,Cython",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/31/9e/b7d881d78cb1024b9876f45863b7019297a29368da7a382c1378f836ffdd/cythonimagetools-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Provides functions (Cython - C) for color analysis in images, including finding unique colors, counting occurrences, and comparing images\r\n\r\n## pip install cythonimagetools\r\n\r\n### Tested against Windows / Python 3.11 / Anaconda\r\n\r\n## Cython (and a C/C++ compiler) must be installed\r\n\r\n\r\n```python\r\nimport numpy as np\r\nfrom cythonimagetools import get_unique_colors, count_colors, get_most_frequent_colors, get_rgb_coords, \\\r\n    get_rgb_coords_parallel, compare_rgb_values_of_2_pics, find_color_ranges\r\n\r\n# Generate a random image\r\nnp.random.seed(0)\r\nx = np.random.randint(0, 9, (1000, 1000, 3))\r\n\r\n# Get unique colors in the image\r\nuniquecolors = get_unique_colors(x)\r\nprint(uniquecolors)\r\n\r\n# Count the occurrence of each color in the image\r\nallcolors = count_colors(x)\r\nprint(allcolors)\r\n\r\n# Get the most frequent colors in the image\r\nmost_freq_colors = get_most_frequent_colors(x)\r\nprint(most_freq_colors)\r\n\r\n# Get RGB coordinates of each pixel in the image\r\nrgb_coords = get_rgb_coords(x)\r\nprint(rgb_coords)\r\n\r\n# Get RGB coordinates in parallel\r\nrgb_coords_parallel = get_rgb_coords_parallel(x)\r\nprint(rgb_coords_parallel)\r\n\r\n# Compare RGB values of two images within a specified tolerance\r\npic1 = np.random.randint(0, 255, (1000, 1000, 3), dtype=np.uint8)\r\npic2 = np.random.randint(0, 200, (1000, 1000, 3), dtype=np.uint8)\r\nru = compare_rgb_values_of_2_pics(pic1, pic2, rmax=10, gmax=10, bmax=10)\r\nprint(ru)\r\n\r\n# Find color ranges in an image based on given colors and tolerance\r\ncolors = np.array([[2, 7, 4], [4, 7, 2]], dtype=np.uint8)\r\nfoundcolors = find_color_ranges(x, colors, rmax=1, gmax=1, bmax=2)\r\nprint(foundcolors)\r\n\r\n\r\nprint(uniquecolors)\r\nprint('--------------------')\r\n\r\nprint(allcolors)\r\nprint('--------------------')\r\n\r\nprint(most_freq_colors)\r\nprint('--------------------')\r\n\r\nprint(rgb_coords)\r\nprint('--------------------')\r\n\r\nprint(rgb_coords_parallel)\r\nprint('--------------------')\r\n\r\nprint(ru)\r\nprint('--------------------')\r\n\r\nprint(colors)\r\nprint('--------------------')\r\n\r\nprint(foundcolors)\r\nprint('--------------------')\r\n\r\n\r\n# [[3 0 5]\r\n#  [3 7 3]\r\n#  [4 2 5]\r\n#  ...\r\n#  [2 0 7]\r\n#  [3 8 5]\r\n#  [2 4 1]]\r\n# --------------------\r\n# [[   3    0    5 1402]\r\n#  [   3    7    3 1380]\r\n#  [   4    2    5 1369]\r\n#  ...\r\n#  [   2    0    7 1413]\r\n#  [   3    8    5 1343]\r\n#  [   2    4    1 1405]]\r\n# --------------------\r\n# [[   2    7    4 1473]]\r\n# --------------------\r\n# [[  3   0   5   0   0]\r\n#  [  3   7   3   0   1]\r\n#  [  4   2   5   0   2]\r\n#  ...\r\n#  [  6   1   1 999 997]\r\n#  [  0   6   4 999 998]\r\n#  [  8   0   6 999 999]]\r\n# --------------------\r\n# [[  3   0   5   0   0]\r\n#  [  3   7   3   0   1]\r\n#  [  4   2   5   0   2]\r\n#  ...\r\n#  [  6   1   1 999 997]\r\n#  [  0   6   4 999 998]\r\n#  [  8   0   6 999 999]]\r\n# --------------------\r\n# [[143  76  62 ...   5 920   0]\r\n#  [153  80  38 ...   9 190   3]\r\n#  [ 42 198  93 ...   8 332   3]\r\n#  ...\r\n#  [ 71  12  64 ...   5   0 995]\r\n#  [174  85 160 ...   7 107 996]\r\n#  [193  37 160 ...   0 817 997]]\r\n# --------------------\r\n# [[2 7 4]\r\n#  [4 7 2]]\r\n# --------------------\r\n# [[  4   7   2 ...   1   0   1]\r\n#  [  4   7   2 ...   2   0  22]\r\n#  [  4   7   2 ...   2   0  24]\r\n#  ...\r\n#  [  4   7   2 ...   2 999 956]\r\n#  [  4   7   2 ...   2 999 970]\r\n#  [  2   7   4 ...   0 999 987]]\r\n# --------------------\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Provides functions (Cython - C) for color analysis in images, including finding unique colors, counting occurrences, and comparing images",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/cythonimagetools"
    },
    "split_keywords": [
        "rgb",
        "cython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59006d24584ddcccf13fc37065f2d0b9aa304774749a4b37e0739c32b8a04506",
                "md5": "8d917f524be51c753014eae515c07c6c",
                "sha256": "1ca193e9275fbd873d8abdd8fd50dbb368404a23e14913706111ce65f0b5a6a3"
            },
            "downloads": -1,
            "filename": "cythonimagetools-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d917f524be51c753014eae515c07c6c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 60488,
            "upload_time": "2023-12-01T10:03:22",
            "upload_time_iso_8601": "2023-12-01T10:03:22.698611Z",
            "url": "https://files.pythonhosted.org/packages/59/00/6d24584ddcccf13fc37065f2d0b9aa304774749a4b37e0739c32b8a04506/cythonimagetools-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "319eb7d881d78cb1024b9876f45863b7019297a29368da7a382c1378f836ffdd",
                "md5": "0c333faecc4941973c8ea66e2e3042cf",
                "sha256": "71eba0adc68571e627025ba0104797c7efc2a7769420385f1f938781320f69c8"
            },
            "downloads": -1,
            "filename": "cythonimagetools-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "0c333faecc4941973c8ea66e2e3042cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 60335,
            "upload_time": "2023-12-01T10:03:24",
            "upload_time_iso_8601": "2023-12-01T10:03:24.871783Z",
            "url": "https://files.pythonhosted.org/packages/31/9e/b7d881d78cb1024b9876f45863b7019297a29368da7a382c1378f836ffdd/cythonimagetools-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-01 10:03:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "cythonimagetools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cythonimagetools"
}
        
Elapsed time: 0.16288s