Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Negative Values When Getting Pixels in Java API

The pixel values I'm getting are negative.

Mat src = Highgui.imread("image.png", Highgui.CV_LOAD_IMAGE_COLOR);
byte[] onePixelData = new byte[3]; 
src.get(x, y, onePixelData);
System.out.println(Arrays.toString(onePixelData)); // outputs [-5, -102, 5]

Am I doing something wrong or is it because Java doesn't support unsigned data types? What's the best way to fix this?