Re: save 16 bit tif

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

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