signed byte array problem
Posted by Nikos Katsikanis on Aug 03, 2006; 11:38am
URL: http://imagej.273.s1.nabble.com/signed-byte-array-problem-tp3701930.html
I create a byte array
redPixels = (byte[])red.getPixels(slice);
I want to sum the values and I try this
long totalRed = 0;
for (int j=0; j<redPixels.length; j++)
totalRed += (byte)redPixels[j];
However because the bytes are signed I get a wrong total.
How to I make the bytes fit into the range 0 - 255 so that me total is
correct. Is there documentation about how ImageJ gets around signed types as
I think this would be helpful.