Ask Your Question

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 -0500

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

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

mfisher gravatar image

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

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


Thanks,I have solved my problem.

ImGladYouCame gravatar imageImGladYouCame ( 2017-10-11 02:46:32 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 52 times

Last updated: Oct 11