How to retrieve float Images from a float stack

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to retrieve float Images from a float stack

gerrit
I'm writing a plugin and like to get images from a stack.
The stack is float, but I'm not able to get float images out of it.

Here is some sample code extracted from my application:

                    IJ.run("LSM Reader", "open="+dirname + System.getProperty("file.separator") + children[i]);
                    ImagePlus imp = IJ.getImage();
                    IJ.run(imp, "Split Channels", "");
                    IJ.selectWindow("C1-"+children[i]);
                    ImagePlus blueimp = IJ.getImage();
                    IJ.run("32-bit", "");

                    IJ.selectWindow("C2-"+children[i]);
                    ImagePlus yellowimp = IJ.getImage();
                    IJ.run("32-bit", "");

C1 and C2 are 32 bit !!

                    ImageStack bluestack = blueimp.getStack();
.....................

                        blueip = bluestack.getProcessor(slice);
                        Rectangle roi = blueip.getRoi();

                        ImageProcessor fblueip = new FloatProcessor(roi.width, roi.height);
                        fblueip = blueip.convertToFloat();
                         ..............
                        ImagePlus testim = NewImage.createFloatImage("RatioIm",roi.width, roi.height, 1, NewImage.FILL_BLACK);

                        testim.setImage(fblueip.getBufferedImage());
                        testim.show();

This gives me an 8 bit image.

Thanks,
Gerrit

--------------------------------------------------
dr. ing. G (Gerrit) Polder
Wageningen UR, Biometris
P.O.Box 100, 6700 AC Wageningen, the Netherlands
http://www.biometris.wur.nl/UK/Staff/Gerrit+Polder/
email: [hidden email]
phone: +31.317.480751
Reply | Threaded
Open this post in threaded view
|

Re: How to retrieve float Images from a float stack

Michael Schmid
Hi Gerrit,

fblueip.getBufferedImage() converts to 8-bit.
If you have a FloatPorcessor fp, simply use
    ImagePlus imp = new ImagePlus("titleString", fp);

Michael
________________________________________________________________

On 2 Jun 2010, at 16:06, Polder, Gerrit wrote:

> I'm writing a plugin and like to get images from a stack.
> The stack is float, but I'm not able to get float images out of it.
>
> Here is some sample code extracted from my application:
>
>                     IJ.run("LSM Reader", "open="+dirname +  
> System.getProperty("file.separator") + children[i]);
>                     ImagePlus imp = IJ.getImage();
>                     IJ.run(imp, "Split Channels", "");
>                     IJ.selectWindow("C1-"+children[i]);
>                     ImagePlus blueimp = IJ.getImage();
>                     IJ.run("32-bit", "");
>
>                     IJ.selectWindow("C2-"+children[i]);
>                     ImagePlus yellowimp = IJ.getImage();
>                     IJ.run("32-bit", "");
>
> C1 and C2 are 32 bit !!
>
>                     ImageStack bluestack = blueimp.getStack();
> .....................
>
>                         blueip = bluestack.getProcessor(slice);
>                         Rectangle roi = blueip.getRoi();
>
>                         ImageProcessor fblueip = new FloatProcessor
> (roi.width, roi.height);
>                         fblueip = blueip.convertToFloat();
>                          ..............
>                         ImagePlus testim = NewImage.createFloatImage
> ("RatioIm",roi.width, roi.height, 1, NewImage.FILL_BLACK);
>
>                         testim.setImage(fblueip.getBufferedImage());
>                         testim.show();
>
> This gives me an 8 bit image.
>
> Thanks,
> Gerrit
>
> --------------------------------------------------
> dr. ing. G (Gerrit) Polder
> Wageningen UR, Biometris
> P.O.Box 100, 6700 AC Wageningen, the Netherlands
> http://www.biometris.wur.nl/UK/Staff/Gerrit+Polder/
> email: [hidden email]
> phone: +31.317.480751