http://imagej.273.s1.nabble.com/Acquiring-the-LUT-of-each-Channel-tp5008167p5008218.html
> I am trying to get the Lookup tables for each channel in a 2 channel tif image programmaticly. I have blue Lut in the first channel and gray in the second. Here are my trys with the output commented.
> I am never able to get the required results as "rgb[255] in the output" should be blue for the first channel and white for the second.
> Any Ideas?
>
>
> [code]
> import ij.ImagePlus;
> import ij.ImageStack;
> import ij.process.ImageProcessor;
> import ij.process.LUT;
> import loci.plugins.BF;
> import loci.plugins.in.ImporterOptions;
>
> public class testLuts {
>
> public void getImpLuts(String path)
> {
> ImagePlus imp = new ImagePlus(path);
> LUT[] luts = imp.getLuts();
>
> for(int i =0; i < luts.length; i++)
> System.out.println(luts[i].toString());
>
> /* Output: Exception in thread "main" java.lang.NullPointerException
> at testLuts.main(testLuts.java:23)
> Java Result: 1 */
>
> }
>
> public void getIpLut(String path)
> {
> ImagePlus imp = new ImagePlus(path);
>
> ImageStack stack = imp.getImageStack();
>
>
> for(int i =0; i < stack.getSize(); i++)
> {
> ImageProcessor ip = stack.getProcessor(i+1);
> LUT l = ip.getLut();
> System.out.println(l.toString());
>
> /* OUTPUT: rgb[0]=black, rgb[255]=blue, min=0.0000, max=255.0000
> rgb[0]=black, rgb[255]=blue, min=0.0000, max=255.0000 */
> }
> }
>
>
> public void withBioFormats(String path)
> {
> try{
> ImporterOptions options = new ImporterOptions();
> options.setId(path);
> options.setAutoscale(true);
> options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE);
>
> ImagePlus[] imps = BF.openImagePlus(options);
> LUT[] luts = imps[0].getLuts();
> ImageStack stack = imps[0].getImageStack();
> for(int i = 0; i < luts.length; i++)
> {
> System.out.println(luts[i].toString());
> }
> for(int i = 0; i < stack.getSize(); i++)
> {
> ImageProcessor ip = stack.getProcessor(i+1);
> LUT lut = ip.getLut();
> System.out.println(lut.toString());
> }
> }
> catch(Exception x){x.printStackTrace();}
> /* OUTPUT
> rgb[0]=black, rgb[255]=blue, min=1.0000, max=68.0000
> rgb[0]=black, rgb[255]=blue, min=0.0000, max=213.0000
> rgb[0]=black, rgb[255]=white, min=0.0000, max=255.0000
> rgb[0]=black, rgb[255]=white, min=0.0000, max=255.0000*/
> }
>
> public static void main(String args[])
> {
> testLuts test = new testLuts();
> String path = "myImage.tif";
> test.withBioFormats(path);
> test.getIpLut(path);
> test.getImpLuts(path);
> }
>
> }
> [/code]
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html