1 | initial version |
Here is an excellent explanation: How to get and modify the pixel of Mat in Java?.
2 | No.2 Revision |
Here is an excellent explanation: How to get and modify the pixel of Mat in Java?.
3 | No.3 Revision |
Here is an excellent explanation: How to get and modify the pixel of Mat in Java? In your case code can be like:
// assume, that Mats with one channel
byte[] sourceBuffer = new byte[srcMat.total()];
byte[] destinationBuffer = new byte[dstMat.total()];
int cols = srcMat.cols();
int rows = srcMat.rows();
for (int y = 0; y < rows; y++){
for (int x = 0; x < cols; x++){
for (int i = 0; i <= 2; i++){
destinationBuffer[y * cols + 3 * x + i] = sourceBuffer(vy * cols + 3 * vx + i)
}
}
}
4 | No.4 Revision |
Here is an excellent explanation: How to get and modify the pixel of Mat in Java? In your case code can be like:
// assume, that Mats with one channel
byte[] sourceBuffer = new byte[srcMat.total()];
byte[] destinationBuffer = new byte[dstMat.total()];
srcMat.get(0, 0, sourceBuffer);
int cols = srcMat.cols();
int rows = srcMat.rows();
for (int y = 0; y < rows; y++){
for (int x = 0; x < cols; x++){
for (int i = 0; i <= 2; i++){
destinationBuffer[y * cols + 3 * x + i] = sourceBuffer(vy * cols + 3 * vx + i)
}
}
}
dstMat.put(0, 0, destinationBuffer);