How to edit/read pixel values in OpenCv from Mat variable?

后端 未结 2 2126
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 03:54

I am looking for an efficient way for editing/reading pixels from Mat (or Mat3b) variable.

I have used :-

Image.at(i,j)
2条回答
  •  一个人的身影
    2020-12-14 04:46

    Here you can see some of the possibilities for fast element access.

    But if you want to do it your way, you need to add a bracket. Otherwise you index computation is not correct:

    for(int i=0; i

    But the layout of the memory is not guaranteed to be contiguous due to padding. So according to this you should rather use a formula like this:

    for(int i=0; i

提交回复
热议问题