# Locate RGB values in a picture! 40 x faster than PIL, 5 x faster than numpy
```python
pip install locate-pixelcolor
```
```python
from locate_pixelcolor import search_colors
# Let's use a 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/
import cv2
path = r"C:\Users\Gamer\Documents\Downloads\pexels-alex-andrews-2295744.jpg"
img = cv2.imread(path)
exa1 = search_colors(pic=img, colors=[(255, 255, 255)])
%timeit search_colors(pic=img, colors=[(255, 255, 255)])
96.8 ms ± 534 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
# You can search for up to 9 different colors at the same time:
search_colors(pic=img, colors=[(255, 255, 255), (0, 0, 0)])
%timeit search_colors(pic=img, colors=[(255, 255, 255),(0, 0, 0)])
132 ms ± 382 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
# Let's compare it with PIL
from PIL import Image
img = Image.open(path)
img = img.convert("RGB")
datas = img.getdata()
def get_coords_with_pil(col):
newData = []
for item in datas:
if item[0] == col[0] and item[1] == col[1] and item[2] == col[2]:
newData.append(item)
return newData
# %timeit get_coords_with_pil(col=(255, 255, 255))
# 3.34 s ± 51.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/locate_pixelcolor",
"name": "locate-pixelcolor",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "rgb,locate,color,colors,numpy",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d4/a5/1c42851b74b30f8a81e2573bda560bb31d5e5ba3773ac8f25540994e019d/locate_pixelcolor-0.10.tar.gz",
"platform": null,
"description": "\n# Locate RGB values in a picture! 40 x faster than PIL, 5 x faster than numpy\n\n\n\n```python\n\npip install locate-pixelcolor\n\n```\n\n\n\n```python\n\nfrom locate_pixelcolor import search_colors\n\n\n\n# Let's use a 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/\n\nimport cv2\n\npath = r\"C:\\Users\\Gamer\\Documents\\Downloads\\pexels-alex-andrews-2295744.jpg\"\n\nimg = cv2.imread(path)\n\nexa1 = search_colors(pic=img, colors=[(255, 255, 255)])\n\n\n\n%timeit search_colors(pic=img, colors=[(255, 255, 255)])\n\n96.8 ms \u00b1 534 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 10 loops each)\n\n\n\n# You can search for up to 9 different colors at the same time:\n\nsearch_colors(pic=img, colors=[(255, 255, 255), (0, 0, 0)])\n\n\n\n%timeit search_colors(pic=img, colors=[(255, 255, 255),(0, 0, 0)])\n\n132 ms \u00b1 382 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 10 loops each)\n\n\n\n# Let's compare it with PIL\n\n\n\nfrom PIL import Image\n\nimg = Image.open(path)\n\nimg = img.convert(\"RGB\")\n\ndatas = img.getdata()\n\n\n\ndef get_coords_with_pil(col):\n\n newData = []\n\n for item in datas:\n\n if item[0] == col[0] and item[1] == col[1] and item[2] == col[2]:\n\n newData.append(item)\n\n return newData\n\n\n\n# %timeit get_coords_with_pil(col=(255, 255, 255))\n\n# 3.34 s \u00b1 51.4 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)\n\n\n\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Locate RGB values in a picture! 40x faster than PIL, 5x faster than numpy",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/locate_pixelcolor"
},
"split_keywords": [
"rgb",
"locate",
"color",
"colors",
"numpy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a2eacacb1425d819c6cddff62ecf0d19cfa1b4e116f65f57609df985de4b61c8",
"md5": "c725183376838556254fa5e30c618b34",
"sha256": "2fcf1faa97e86e93fd2e8ab93208a45ad2efb74517b0c267443533c8d1c51bc4"
},
"downloads": -1,
"filename": "locate_pixelcolor-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c725183376838556254fa5e30c618b34",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5419,
"upload_time": "2022-12-21T02:40:49",
"upload_time_iso_8601": "2022-12-21T02:40:49.829158Z",
"url": "https://files.pythonhosted.org/packages/a2/ea/cacb1425d819c6cddff62ecf0d19cfa1b4e116f65f57609df985de4b61c8/locate_pixelcolor-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d4a51c42851b74b30f8a81e2573bda560bb31d5e5ba3773ac8f25540994e019d",
"md5": "6b797c3b96f4dc922eac27ba6fd44df0",
"sha256": "9439a9e07a004e90bb0091d1b97ba900e15c0735fbcb1b65cf39dca393abaaf7"
},
"downloads": -1,
"filename": "locate_pixelcolor-0.10.tar.gz",
"has_sig": false,
"md5_digest": "6b797c3b96f4dc922eac27ba6fd44df0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3822,
"upload_time": "2022-12-21T02:40:51",
"upload_time_iso_8601": "2022-12-21T02:40:51.445558Z",
"url": "https://files.pythonhosted.org/packages/d4/a5/1c42851b74b30f8a81e2573bda560bb31d5e5ba3773ac8f25540994e019d/locate_pixelcolor-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-21 02:40:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "locate_pixelcolor",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numexpr",
"specs": []
},
{
"name": "numpy",
"specs": []
}
],
"lcname": "locate-pixelcolor"
}