Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi! Try something like this:


// assume, that Mat with three channel
byte[] sourceBuffer = new byte[srcMat.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 * 3; x += 3){
    for (int channelId = 0; channelId < 3; channelId++){
          sourceBuffer[y * cols + x + channelId] = 0;
    }
  }
}
srcMat.put(0, 0, destinationBuffer);

Hi! Try something like this:


// assume, that Mat with three channel
byte[] sourceBuffer = new byte[srcMat.total()];
byte[srcMat.total() * srcMat.channels()];
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 * 3; x += 3){
    for (int channelId = 0; channelId < 3; channelId++){
          sourceBuffer[y * cols + x + channelId] = 0;
    }
  }
}
srcMat.put(0, 0, destinationBuffer);