# Umat equivalent of Mat.at() to access specific pixel

**URL:** <https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779>\
**Category:** C++\
**Tags:** tapi, umat\
**Created:** [October 21, 2021, 4:38pm UTC](https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779 "2021-10-21T16:38:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehardin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/ehardin/32/2541_2.png) [@ehardin](https://forum.opencv.org/u/ehardin)\
**Post date:** [October 21, 2021, 4:38pm UTC](https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779/1 "2021-10-21T16:38:46Z")

</div>

Using OCV 4.5; C++, Visual Studio 2017; MFC; Windows 10

I am trying to convert some Mat code to UMat. An example line would be

> myMat.at(i, j) = temp\_s;

I get the error that ‘at’ is not a member of Umat.

What would be the equivalent for a UMat. In other words, I want to access each pixel of a UMat and make changes.

Ed

---

<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 21, 2021, 4:43pm UTC](https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779/2 "2021-10-21T16:43:28Z")

</div>

there is no such thing, this is where CPU and GPU progamming differs

in general, there are no “random access” operations on the GPU  
(no (i,j), no drawing)

if you cannot express your idea “as vectors”, it’s not possible on the GPU.

---

<div class="post-metadata">

**Author:** ![ehardin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/ehardin/32/2541_2.png) [@ehardin](https://forum.opencv.org/u/ehardin)\
**Post date:** [October 21, 2021, 5:22pm UTC](https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779/3 "2021-10-21T17:22:03Z")

</div>

Thanks…I was afraid that was the case.

Ed

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [October 22, 2021, 4:43pm UTC](https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779/4 "2021-10-22T16:43:38Z")

</div>

yes, UMats are opaque to the CPU. you’d have to “`getMat`” the contents of a UMat, which is returned as a Mat… and then you probably need to stick it in another UMat again

[https://docs.opencv.org/master/d7/d45/classcv\_1\_1UMat.html#a3d84c72c06ddd55d35b87c3d222d2674](https://docs.opencv.org/master/d7/d45/classcv_1_1UMat.html#a3d84c72c06ddd55d35b87c3d222d2674)

> **[OpenCV Transparent API | LearnOpenCV #](https://learnopencv.com/opencv-transparent-api/)**
>
> How to use Transparent API ( T-API or TAPI ) in OpenCV 3 to significantly speed up existing code. TAPI uses OpenCL under the hood.

---

<div class="post-metadata">

**Author:** ![ehardin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/ehardin/32/2541_2.png) [@ehardin](https://forum.opencv.org/u/ehardin)\
**Post date:** [October 22, 2021, 7:29pm UTC](https://forum.opencv.org/t/umat-equivalent-of-mat-at-to-access-specific-pixel/5779/5 "2021-10-22T19:29:15Z")

</div>

Thanks. Apparently that would defeat the purpose of me trying to use UMat in the first place…oh well.
