Daan,
I think ImageJ uses the Max and Min pixel values to define the upper
and lower bounds of the image intensity. You can adjust them in the
brightness and contrast pane. When you then convert to 8 bit, it
defines the min as 0 and max as 255 and bins all the other pixels
accordingly. Adjusting them changes the short to byte cast.
So, if your data goes from, say 100 to 1434, then:
100 -> 0
1434 - > 255
and anything in between is converted accordingly:
x -> 255*(x-min)/(max-min)
so in the example I've given:
500 -> 255*(500-100)/(1434-100) -> 76
Hope that helps.
--David
On Dec 3, 2007, at 12:21 PM, Daan Zhu wrote:
> Dear ImageJ users,
> I am sorry for the confusion of my question. I need to use C++ to
> rewrite ShortProcessor to ByteProcessor converter.
> This function is perfect in imageJ. Only three lines.
>
> ImageProcessor ip = imp.getProcessor; //ip is ShortProcessor, imp
> is ImagePlus
> java.awt.Image img = ip.createImage();
> return new ByteProcessor(img);
>
> I am very surprise the output contrast is very closed to the
> original contrast in 12-bit. Could you please any people know
> how the above code works? Especially how to chop 2 bytes to 1 byte?
>
> My image data is DICOM image in signed 12-bit, the range is from
> -2048 to +2048.
>
> Thank you for your time.
>
> Regards,
>
> Daan