Re: save 16 bit tif

Posted by alessandra griffa on
URL: http://imagej.273.s1.nabble.com/save-16-bit-tif-tp3695929p3695933.html

Hi!

I tried with that, and also I tried to use IJ.save instead of
FileSaver.saveAsTiffStack, but I always get the exception:

java.lang.ClassCastException: [F cannot be cast to [S
 at ij.io.ImageWriter.write16BitStack(ImageWriter.java:78)
 at ij.io.ImageWriter.write(ImageWriter.java:213)
 at ij.io.TiffEncoder.write(TiffEncoder.java:116)
 at ij.io.FileSaver.saveAsTiffStack(FileSaver.java:109)
 at ij.io.FileSaver.saveAsTiff(FileSaver.java:69)
 at ij.plugin.filter.Writer.run(Writer.java:20)
 at
ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:243)
 at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:102)
 at ij.IJ.runPlugIn(IJ.java:133)
 at ij.Executer.runCommand(Executer.java:95)
 at ij.Executer.run(Executer.java:49)
 at ij.IJ.run(IJ.java:230)
 at ij.IJ.saveAs(IJ.java:1162)
 at ij.IJ.save(IJ.java:1095)
 at Detect_.run(Detect_.java:447)
 at java.lang.Thread.run(Unknown Source)

Alessandra



2008/6/6 Thomas Boudier <[hidden email]>:

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