Login  Register

Re: ShortPorcessor convert to ByteProcessor

Posted by Dimiter Prodanov-2 on Dec 04, 2007; 9:38am
URL: http://imagej.273.s1.nabble.com/ShortPorcessor-convert-to-ByteProcessor-tp3697863p3697864.html

Dear Daan,

use of awt.Image is superfluous.
I think you can use something like new ByteProcessor(ImagePlus imp);
To convert from 12 bit to 8 bit ImageJ scales down the bytes linearily.
And I suggest that you really look into the source code before asking
questions.

Cheers

Dimiter Prodanov



--------------------
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