Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to edit/reading pixels from Mat(Vec3b) using Java

Hi guys, how to edit or reading pixels from Mat with type Vec3b using java. In c++ we can use something like this

matImage.at<Vec3b>(x,y)[0]; // for blue
matImage.at<Vec3b>(x,y)[1]; // for grey
matImage.at<Vec3b>(x,y)[2]; // for red

or we can use something like this

for(int i=0; i<A.rows; i++){
   for(int j=0; j<A.cols; j++){
           A.data[A.channels()*(A.cols*i + j) + 0] = 0;
           A.data[A.channels()*(A.cols*i + j) + 1] = 0;
           A.data[A.channels()*(A.cols*i + j) + 2] = 0;
    }
}

but how to do it using Java? i already search it, i got stuck, i still dont have clear idea how to edit/reading it in Java language.