Ask Your Question
2

Mat element access

asked 2012-09-04 04:19:57 -0600

mrgloom gravatar image

updated 2015-12-27 07:53:40 -0600

I read this article, but I can't find how to access Mat element like this

img[y][x]=100;

is it possible? And another question is how can I don't omit type of Mat, but check types on compilation time.

instead of

img.at<uchar>(i,j)

something like this

img[i][j]
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-09-04 04:48:58 -0600

Vladislav Vinogradov gravatar image

You can use template version of Mat:

Mat_<Vec3b> bgrMat;
bgrMat(y, x) = Vec3b(0,0,0);
Vec3b* row = bgrMat[y] // pointer to mat row
edit flag offensive delete link more

Comments

So I can access pixel like bgrMat(y, x) = Vec3b(B,G,R); ?

mrgloom gravatar imagemrgloom ( 2012-09-05 01:09:27 -0600 )edit

Yes, for Mat_<Vec3b>.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2012-09-05 01:29:58 -0600 )edit

Question Tools

Stats

Asked: 2012-09-04 04:19:57 -0600

Seen: 3,195 times

Last updated: Sep 04 '12