Retrieving LUTs from ImagePlus

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

Retrieving LUTs from ImagePlus

Mohamed Tleis
Dear Wayne and imageJ members,

Previously I asked how to acquire the LUT from each Channel in an
ImagePlus using BioFormats and thanks to Wayne my problem was solved(
http://imagej.1557.x6.nabble.com/Acquiring-the-LUT-of-each-Channel-td5008167.html)

Now I want to replace the bioformats package with the formatsgpl.jar
which has minimal Classes included. I created this minimal example to
show that the luts wouldn't be retrieved from the ImagePlus object. Any
hints?


[code]

import ij.*;
import ij.process.*;
import java.awt.image.*;
import loci.formats.*;
import loci.formats.gui.*;

public class testFormatsGPL {

     public void run()
     {
         String dir = "/home/mohamed/Desktop/test/";
         String name = "yeastNha1.tif";

         IFormatReader reader = null;
     BufferedImageReader bir = null;
     try {
             reader = new ImageReader();
             reader.setId(dir+name);
             bir = new BufferedImageReader(reader);
             BufferedImage input = bir.openImage(0);
             ImagePlus imp = new ImagePlus("imp", input);

             LUT[] luts = ((CompositeImage)imp).getLuts();
             ImageStack stack = imp.getImageStack();

             for(int i = 0; i < luts.length; i++)
             {
                 // This one failes with Null Pointer Exception
                 System.out.println("Imp luts: " + luts[i].toString());
             }
             for(int i = 0; i < stack.getSize(); i++)
             {
                 // Is this correct? How could it read Lut from
Processor but not from Imp?
                 ImageProcessor ip = stack.getProcessor(i+1);
                 LUT lut = ip.getLut();
                 System.out.println("per Ip: " + lut.toString());
             }

         }
         catch(Exception x){x.printStackTrace();}
     }


     public static void main(String args[])
     {
         testFormatsGPL test = new testFormatsGPL();
         test.run();
     }
[/code]

Thanks in Advance,

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html