Changeset 5992


Ignore:
Timestamp:
03/04/10 12:23:41 (10 years ago)
Author:
melissa
Message:

Set lookup tables correctly, if they are present.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/utils/Read_Image.java

    r5325 r5992  
    33// 
    44 
     5import ij.CompositeImage; 
    56import ij.IJ; 
    67import ij.ImagePlus; 
     
    910import ij.plugin.PlugIn; 
    1011import ij.process.ImageProcessor; 
     12import ij.process.LUT; 
    1113import java.io.IOException; 
    1214import loci.formats.ChannelSeparator; 
     
    3133      int height = r.getSizeY(); 
    3234      ImageStack stack = new ImageStack(width, height); 
     35      byte[][][] lookupTable = new byte[r.getSizeC()][][]; 
    3336      for (int i=0; i<num; i++) { 
    3437        IJ.showStatus("Reading image plane #" + (i + 1) + "/" + num); 
    3538        ImageProcessor ip = r.openProcessors(i)[0]; 
    3639        stack.addSlice("" + (i + 1), ip); 
     40        int channel = r.getZCTCoords(i)[1]; 
     41        lookupTable[channel] = r.get8BitLookupTable(); 
     42      } 
     43      IJ.showStatus("Constructing image"); 
     44      ImagePlus imp = new ImagePlus(name, stack); 
     45 
     46      // apply color lookup tables, if present 
     47      // this requires ImageJ v1.39 or higher 
     48      if (r.isIndexed()) { 
     49        CompositeImage composite = 
     50          new CompositeImage(imp, CompositeImage.COLOR); 
     51        for (int c=0; c<r.getSizeC(); c++) { 
     52          composite.setPosition(c + 1, 1, 1); 
     53          LUT lut = 
     54            new LUT(lookupTable[c][0], lookupTable[c][1], lookupTable[c][2]); 
     55          composite.setChannelLut(lut); 
     56        } 
     57        composite.setPosition(1, 1, 1); 
     58        imp = composite; 
    3759      } 
    3860      r.close(); 
    39       IJ.showStatus("Constructing image"); 
    40       ImagePlus imp = new ImagePlus(name, stack); 
     61 
    4162      imp.show(); 
    4263      IJ.showStatus(""); 
Note: See TracChangeset for help on using the changeset viewer.