Ask Your Question
0

How to get every pixel's value of R, G and B from the Mat of type CV_8UC3 in Java?

asked 2017-10-10 08:57:38 -0600

ImGladYouCame gravatar image

I used Mat :: get (row, col, data) method to get each pixel, but how to get each pixel R, G, B value?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2017-10-10 12:56:26 -0600

mfisher gravatar image

updated 2017-10-11 02:36:10 -0600

Mat m;
byte[] b = new byte[3];
m.get(y, x, b);
//Assuming BGR Format
// blue = b[0]
// green = b[1]
// red = b[2]

Don't do this in a loop. To access many pixels at a time, use a larger buffer.

edit flag offensive delete link more

Comments

Thanks,I have solved my problem.

ImGladYouCame gravatar imageImGladYouCame ( 2017-10-11 02:46:32 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-10-10 08:57:38 -0600

Seen: 327 times

Last updated: Oct 11 '17