I\'m trying to access Pixel by Pixel of an IplImage. Im using Java and Processing, and sometimes I need to access pixel by pixel. I\'ve done this so far, but I don\'t know what\
The fastest way to iterate over each pixel in JavaCV is:
ByteBuffer buffer = image.getByteBuffer();
for(int y = 0; y < image.height(); y++) {
for(int x = 0; x < image.width(); x++) {
int index = y * image.widthStep() + x * image.nChannels();
// Used to read the pixel value - the 0xFF is needed to cast from
// an unsigned byte to an int.
int value = buffer.get(index) & 0xFF;
// Sets the pixel to a value (greyscale).
buffer.put(index, value);
// Sets the pixel to a value (RGB, stored in BGR order).
buffer.put(index, blue);
buffer.put(index + 1, green);
buffer.put(index + 2, red);
}
}