Login  Register

Re: How to correct 32bits(RGB) images?

Posted by Michael Schmid on May 21, 2010; 2:29pm
URL: http://imagej.273.s1.nabble.com/How-to-correct-32bits-RGB-images-tp3688233p3688236.html

Hi Natasha,

> -> I used before this instruction rgbG[i]&255 to eliminate the sign  
> bit.
>     Can I eliminate the sign bit and convert it to short at the  
> same time by
> only writing:
>     rgbG1=(short)rgbG[i]&0XFFFF  where rgbG[] is a byte array ?
no, you would have to write
  int r = (rgb[i]&0xff0000)>>16;
  int g = (rgb[i]&0xff00)>>8;
  int b =  rgb[i]&0xff;

output data will be 0-255 for all 3 channels.

>     ImageProcessor.toFloat(int channelNumber, FloatProcessor fp)
that's an easy way if you do float calculations, and it has the  
advantage that you can write code that works with all types of images  
(gray&float), see my code outline in the last post on this subject.  
Again, you will get float data 0-255 for 8-bit and rbg images, and  
0-65535 for 16-bit images. Back conversion by ip.setPixels(t  
channelNumber, FloatProcessor fp) uses the same range (lower/higher  
float pixel values will be mapped to 0 or the maximum).

> ->And after the images are shifted now for example to [0 , 65535]  
> shouldn't
> I ranging them again to [−32768 , 32767] to show them normally  
> with imageJ?
hummm, it is not really clear what you refer to. 16-bit data in  
ImageJ are unsigned, 0-65535 by definition, but you can have a  
calibration that maps that range to signed short, [−32768, 32767],  
for readout of pixel values.

When converting 16-bit or float data to 8-bit grayscale or rgb it  
depends on whether 'scale conversions' is true; if it is true, the  
current display (usually min-max of data) range is mapped to 0-255,  
if false, only the 0-255 range of short (float) data is used and  
becomes 0-255 of the 8-bit data (in that case you won't get better  
resolution by using 16 bits). This is fundamentally different from  
Photoshop, where the highest value of 16-bit data is read out as  
'255', and 16-bit data have the same range as 8-bit data, but better  
resolution.

Hope this helps,

Michael