开发者

pointer uchar* question in opencv vc++ 2008

img_hsv is a Mat element of an hsv image!

when i give cout<<*img_hsv.data+10; it gives true value of the pi开发者_StackOverflowxel ie 79 as output. but when i assign uchar * a=img_hsv.data+10; it gives me some other value... can you please explain me why is this the case? thanks!


In the first case, you are first getting the content of pointer img_hsv.data and then adding 10 to that value and displaying it. In the second case you are just incrementing the pointer by 10 units. This incremented value points to a memory location. So a will contain the address of the location hence it will be different from the printed value. If you meant that *a is giving different value, then it is because of the operator precedence. In the first case, pointer is dereferened first and then 10 is added to the dereferenced value, and in the second case you are incrementing the pointer first and then dereferencing it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜