Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can acess the pixels from java like:

Mat image = ...
byte [] data = new byte[mat.total() * mat.channels()];
image.get(0,0, data);

note, that this is an 1d array, and it's elements are bytes, not integers. you would treat it like:

byte value = data[ (y * mat.cols() + x) * mat.channels() ]

you can acess the pixels from java like:

Mat image = ...
byte [] data = new byte[mat.total() * mat.channels()];
image.get(0,0, data);

note, that this is an 1d array, and it's elements are bytes, not integers. you would treat it like:

byte value = data[ (y * mat.cols() + x) * mat.channels() ]

(ofc. mat.channels() == 1 for a grayscale image)

you can acess access the pixels from java like:

Mat image = ...
byte [] data = new byte[mat.total() * mat.channels()];
image.get(0,0, data);

note, that this is an 1d array, and it's elements are bytes, not integers. you would treat it like:

byte value = data[ (y * mat.cols() + x) * mat.channels() ]

(ofc. mat.channels() == 1 for a grayscale image)