# Detect an rgb color image?

**URL:** <https://forum.opencv.org/t/detect-an-rgb-color-image/14924>\
**Category:** Python\
**Created:** [October 19, 2023, 10:38am UTC](https://forum.opencv.org/t/detect-an-rgb-color-image/14924 "2023-10-19T10:38:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sp000n](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@sp000n](https://forum.opencv.org/u/sp000n)\
**Post date:** [October 19, 2023, 10:38am UTC](https://forum.opencv.org/t/detect-an-rgb-color-image/14924/1 "2023-10-19T10:38:43Z")

</div>

hi,

i have been experimenting with opencv for a little bit now  
i noticed that i cant matchTemplate with rgb, the haystack and needle must be grayscale format, but in my circumstance i really need color

is there a way to matchTemplate rgb/bgr with cv2 in python, or is there a different function entirely for finding matches with color?

thanks!

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 19, 2023, 11:19am UTC](https://forum.opencv.org/t/detect-an-rgb-color-image/14924/2 "2023-10-19T11:19:49Z")

</div>

> [@sp000n](#):
>
> but in my circumstance i really need color

please explain, why, show data, code …

> [@sp000n](#):
>
> is there a way to matchTemplate rgb/bgr with cv2 in python

you can try [colorMatchTemplate()](https://docs.opencv.org/4.x/da/d17/group __ximgproc__ filters.html#ga370f180e4a52231ba218adbb4a65a9ca)  
(but you need opencv-contrib-python)

---

<div class="post-metadata">

**Author:** ![sp000n](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@sp000n](https://forum.opencv.org/u/sp000n)\
**Post date:** [October 19, 2023, 11:53am UTC](https://forum.opencv.org/t/detect-an-rgb-color-image/14924/3 "2023-10-19T11:53:14Z")

</div>

the haystack data i am working with is in very low resolution(natively, there is nothing i can do about this, unfortunately), and trying to match a needle in this resolution without color produces errors very often

only way to distinguish needle from similar artifacts is by color
