Re: Negative values in binary byte arrary viewed in Netbeans

Posted by nellypledge on
URL: http://imagej.273.s1.nabble.com/Negative-values-in-binary-byte-arrary-viewed-in-Netbeans-tp5016033p5016038.html

Thanks Michael for those crucial details.

Could I also ask if I can update the contents of the getPixels byte array reference by simply assigning values to the reference? I've always struggled with java 'pointers'.

Thanks
Neil


From: "Michael Schmid-3 [via ImageJ]" <ml-node+[hidden email]>
Sent: Mar 31, 2016 11:50 AM
To: Anthony, Neil
Subject: Re: Negative values in binary byte arrary viewed in Netbeans

Hi Neil,

when you access the pixels array of a ByteProcessor, you have to apply a
mask 0xff=255 to get the pixel value:
  int value = pixels[x+y*width]&0xff;
That's because the ImageJ ByteProcessor assumes unsigned values 0-255 as
usual in image processing, but the Java type 'byte' is signed, with a
range -128...+127.
It's the same for a ShortProcessor, there you have to use a mask of 0xffff.

Michael
____________________________________________________________

On Thu, March 31, 2016 03:38, nellypledge wrote:

> Hi,
> I'm debugging a plugin and I see that the values of the byte array of an
> ImageProcessor (using both get() and getPixels()) are 0's and -1's...  I
> think the -1's are the true values (what are 255 in the image when you
> mouse-over), but haven't gone to lengths to figure that out.
>
> When I assign a value of 255 to the image during the code it behaves as it
> should, and I'm curious to know the reason for the -1's?
>
> Using get() and put() works well, but when I getPixels() and edit the
> values
> in that referenced array it does appear to change, and wondered if there
> are
> subtleties between the two and if the -1's are related.
>
> Thanks in advance for your time.
> Neil
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Negative-values-in-binary-byte-arrary-viewed-in-Netbeans-tp5016033.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Negative-values-in-binary-byte-arrary-viewed-in-Netbeans-tp5016033p5016037.html
To unsubscribe from Negative values in binary byte arrary viewed in Netbeans, click here.
NAML



This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).