Login  Register

Re: save 16 bit tif

Posted by Thomas Boudier on Jun 06, 2008; 12:16pm
URL: http://imagej.273.s1.nabble.com/save-16-bit-tif-tp3695929p3695932.html

Hi,

Use StackConverter instead of ImageConverter :

StackConverter c = new StackConverter(imp);
c.convertToGray16();

Thomas


alessandra griffa a écrit :

> I tried this too, but the problem is at the point of the instruction
> *saverstack.saveAsTiffStack(pathout + "/" + filename + ".tif");*
> I get the image converted, but I am not able to save it?
> Am i missing something?
> Is there another class to save?
>
> 2008/6/6 Thomas Boudier <[hidden email]>:
>
>> Hi Alessandra,
>>
>> Why not use the imageConverter class :
>>
>> import ij.*;
>> import ij.process.*;
>> import ij.gui.*;
>> import java.awt.*;
>> import ij.plugin.filter.*;
>>
>> public class Filter_Plugin implements PlugInFilter {
>>        ImagePlus imp;
>>
>>        public int setup(String arg, ImagePlus imp) {
>>                this.imp = imp;
>>                return DOES_ALL;
>>        }
>>
>>        public void run(ImageProcessor ip) {
>>                ImageConverter c=new ImageConverter(imp);
>>                c.convertToGray16();
>>        }
>>
>> }
>>
>> Do not forget to adjust the contrast before converting to 16 bits.
>>
>> Thomas
>>
>>
>>
>>> I have an ImagePlus stack ('impoutstack'), 32 bit, and I would like to
>> save
>>> it as a 16 bit tif stack.
>>> I did this:
>>>
>>> *ImageProcessor ip = impoutstack.getProcessor();
>>> impoutstack.setProcessor(null, ip.convertToShort(true)); // conversion
>> impoutstack.setCalibration(impoutstack.getCalibration()); // update
>> calibration
>>> FileSaver saverstack = new FileSaver(impoutstack);*
>>> *saverstack.saveAsTiffStack(pathout + "/" + filename + ".tif");*
>>>
>>> but at run time I get the exception
>>>
>>> *java.lang.ClassCastExceprion at ij.io.ImageWriter.write16BitStack*
>>>
>>> Does anyone know how to easily save as 16 bit tif stack?
>>>
>>> Thanks a lot,
>>> Alessandra
>>>
>>>
>
>

--
/*****************************************************/
     Thomas Boudier, MCU Université Paris 6,
     UMR 7101 / IFR 83. Bat A 328, Jussieu.
     Tel : 01 44 27 35 78  Fax : 01 44 27 25 08
/****************************************************/