Changeset 6599


Ignore:
Timestamp:
06/29/10 14:31:19 (9 years ago)
Author:
curtis
Message:

Backport r6598 to 4.2 branch.

Location:
branches/4.2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

    • Property svn:mergeinfo changed
      /trunkmerged: 6598
  • branches/4.2/components

  • branches/4.2/components/bio-formats/src

  • branches/4.2/components/bio-formats/src/loci/formats/ChannelFiller.java

  • branches/4.2/components/bio-formats/src/loci/formats/ImageTools.java

  • branches/4.2/components/bio-formats/src/loci/formats/in/FakeReader.java

  • branches/4.2/components/loci-plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins/in/Colorizer.java

    r6589 r6599  
    8181      LUT[] luts; 
    8282 
    83       // get each channel's color model 
     83      // get LUT for each channel 
    8484      final ImageStack stack = imp.getStack(); 
    8585      final String stackOrder = dimSwapper.getDimensionOrder(); 
     
    9292      for (int c=0; c<cSize; c++) { 
    9393        final int index = FormatTools.getIndex(stackOrder, 
    94           zSize, cSize, tSize, stackSize, 0, c, 0) + 1; 
    95         final ColorModel cm = stack.getProcessor(index).getColorModel(); 
    96  
    97         // HACK: ImageProcessorReader always assigns an ij.process.LUT object 
    98         // as the color model. If we don't get one, we know ImageJ created a 
    99         // default color model instead, which we can discard. 
    100         if (cm instanceof LUT) { 
    101           channelLUTs[c] = (LUT) cm; 
    102           hasChannelLUT = true; 
    103         } 
     94          zSize, cSize, tSize, stackSize, 0, c, 0); 
     95        channelLUTs[c] = (LUT) 
     96          imp.getProperty(ImagePlusReader.PROP_LUT + index); 
     97        if (channelLUTs[c] != null) hasChannelLUT = true; 
    10498      } 
    10599 
  • branches/4.2/components/loci-plugins/src/loci/plugins/in/ImagePlusReader.java

    r6589 r6599  
    3030import ij.io.FileInfo; 
    3131import ij.process.ImageProcessor; 
    32  
     32import ij.process.LUT; 
     33 
     34import java.awt.image.ColorModel; 
    3335import java.io.File; 
    3436import java.io.IOException; 
     
    7173  public static final String PROP_SERIES = "Series"; 
    7274 
     75  /** Special property prefix for storing planar LUTs. */ 
     76  public static final String PROP_LUT = "LUT-"; 
     77 
    7378  // -- Fields -- 
    7479 
     
    184189    ImageStack stack = null; 
    185190 
     191    final List<LUT> luts = new ArrayList<LUT>(); 
    186192    if (options.isVirtual()) { 
    187193      // CTR FIXME: Make virtual stack work with different color modes? 
    188194      reader.setSeries(s); 
    189       // NB: ImageJ 1.39+ is required for VirtualStack 
    190195      BFVirtualStack virtualStack = new BFVirtualStack(options.getId(), 
    191196        reader, false, false, options.isRecord()); 
     
    205210        updateTiming(s, i, current++, total); 
    206211 
    207         String label = constructSliceLabel(i, 
     212        final String label = constructSliceLabel(i, 
    208213          reader, process.getOMEMetadata(), s, 
    209214          process.getZCount(s), process.getCCount(s), process.getTCount(s)); 
    210215 
    211216        // get image processor for ith plane 
    212         ImageProcessor[] p = reader.openProcessors(i, 
     217        final ImageProcessor[] p = reader.openProcessors(i, 
    213218          region.x, region.y, region.width, region.height); 
    214219        if (p == null || p.length == 0) { 
     
    217222 
    218223        // add plane to image stack 
    219         int w = region.width, h = region.height; 
     224        final int w = region.width, h = region.height; 
    220225        if (stack == null) stack = new ImageStack(w, h); 
    221226 
    222         for (ImageProcessor ip : p) stack.addSlice(label, ip); 
     227        for (ImageProcessor ip : p) { 
     228          // HACK: ImageProcessorReader always assigns an ij.process.LUT object 
     229          // as the color model. If we don't get one, we know ImageJ created a 
     230          // default color model instead, which we can discard. 
     231          final ColorModel cm = ip.getColorModel(); 
     232          final LUT lut = cm instanceof LUT ? (LUT) cm : null; 
     233          luts.add(lut); 
     234 
     235          stack.addSlice(label, ip); 
     236        } 
    223237      } 
    224238    } 
     
    226240    notifyListeners(new StatusEvent(1, 1, "Creating image")); 
    227241 
    228     ImagePlus imp = createImage(stack, s, fi); 
     242    final ImagePlus imp = createImage(stack, s, fi); 
    229243    imps.add(imp); 
     244 
     245    // NB: Save individual planar LUTs as properties, for later access. 
     246    // This step is necessary because ImageStack.addSlice only extracts the 
     247    // pixels from the ImageProcessor, and does not preserve the ColorModel. 
     248    for (int i=0; i<luts.size(); i++) { 
     249      final LUT lut = luts.get(i); 
     250      if (lut != null) imp.setProperty(PROP_LUT + i, lut); 
     251    } 
    230252  } 
    231253 
Note: See TracChangeset for help on using the changeset viewer.