Ignore:
Timestamp:
06/29/10 08:43:24 (10 years ago)
Author:
curtis
Message:

Backport recent bugfixes to 4.2 branch.

Location:
branches/4.2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

  • 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/IFormatReader.java

    r6514 r6584  
    130130   * Returns false if {@link #isIndexed()} is false, or if {@link #isIndexed()} 
    131131   * is true and the lookup table represents "real" color data. Returns true 
    132    * if {@link #isIndexed} is true and the lookup table is only present to aid 
     132   * if {@link #isIndexed()} is true and the lookup table is only present to aid 
    133133   * in visualization. 
    134134   */ 
  • 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

    r6559 r6584  
    3737 
    3838import loci.formats.ChannelFiller; 
     39import loci.formats.DimensionSwapper; 
     40import loci.formats.FormatTools; 
    3941import loci.formats.ImageReader; 
    4042import loci.plugins.BF; 
     
    6769    final ImporterOptions options = process.getOptions(); 
    6870    final ImageProcessorReader reader = process.getReader(); 
     71    final DimensionSwapper dimSwapper = process.getDimensionSwapper(); 
    6972    final ChannelFiller channelFiller = process.getChannelFiller(); 
    7073    final ImageReader imageReader = process.getImageReader(); 
     
    8083      // get each channel's color model 
    8184      final ImageStack stack = imp.getStack(); 
    82       final int sizeC = reader.getEffectiveSizeC(); 
    83       final LUT[] channelLUTs = new LUT[sizeC]; 
     85      final String stackOrder = dimSwapper.getDimensionOrder(); 
     86      final int zSize = imp.getNSlices(); 
     87      final int cSize = imp.getNChannels(); 
     88      final int tSize = imp.getNFrames(); 
     89      final int stackSize = imp.getStackSize(); 
     90      final LUT[] channelLUTs = new LUT[cSize]; 
    8491      boolean hasChannelLUT = false; 
    85       for (int c=0; c<sizeC; c++) { 
    86         final int index = reader.getIndex(0, c, 0) + 1; 
     92      for (int c=0; c<cSize; c++) { 
     93        final int index = FormatTools.getIndex(stackOrder, 
     94          zSize, cSize, tSize, stackSize, 0, c, 0) + 1; 
    8795        final ColorModel cm = stack.getProcessor(index).getColorModel(); 
    8896 
     
    140148      } 
    141149 
    142       final boolean doComposite = mode != -1 && sizeC > 1 && sizeC <= 7; 
     150      final boolean doComposite = mode != -1 && cSize > 1 && cSize <= 7; 
    143151      if (doComposite) { 
    144152        CompositeImage compImage = new CompositeImage(imp, mode); 
     
    151159          imp.getProcessor().setColorModel(luts[0]); 
    152160        } 
    153         if (mode != -1 && sizeC > 1) { 
     161        if (mode != -1 && cSize > 1) { 
    154162          // NB: Cannot use CompositeImage with more than seven channels. 
    155163          BF.warn(options.isQuiet(), "Data has too many channels for " + 
  • branches/4.2/components/loci-plugins/src/loci/plugins/in/Concatenator.java

    r6495 r6584  
    3939 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/loci-plugins/src/loci/plugins/in/Concatenator.java">SVN</a></dd></dl> 
    4040 * 
     41 * @author Curtis Rueden ctrueden at wisc.edu 
    4142 * @author Melissa Linkert melissa at glencoesoftware.com 
    4243 */ 
     
    4647  public List<ImagePlus> concatenate(List<ImagePlus> imps) { 
    4748 
    48     List<Integer> widths = new ArrayList<Integer>(); 
    49     List<Integer> heights = new ArrayList<Integer>(); 
    50     List<Integer> types = new ArrayList<Integer>(); 
    51     List<ImagePlus> newImps = new ArrayList<ImagePlus>(); 
     49    // list of output (possibly concatenated) images 
     50    final List<ImagePlus> outputImps = new ArrayList<ImagePlus>(); 
    5251 
    53     for (int j=0; j<imps.size(); j++) { 
    54       ImagePlus imp = imps.get(j); 
    55       int wj = imp.getWidth(); 
    56       int hj = imp.getHeight(); 
    57       int tj = imp.getBitDepth(); 
     52    for (ImagePlus imp : imps) { 
     53      final int width = imp.getWidth(); 
     54      final int height = imp.getHeight(); 
     55      final int type = imp.getType(); 
     56      final int cSize = imp.getNChannels(); 
     57      final int zSize = imp.getNSlices(); 
     58      final int tSize = imp.getNFrames(); 
     59 
    5860      boolean append = false; 
    59       for (int k=0; k<widths.size(); k++) { 
    60         int wk = widths.get(k); 
    61         int hk = heights.get(k); 
    62         int tk = types.get(k); 
     61      for (int k=0; k<outputImps.size(); k++) { 
     62        final ImagePlus outputImp = outputImps.get(k); 
     63        final int w = outputImp.getWidth(); 
     64        final int h = outputImp.getHeight(); 
     65        final int outType = outputImp.getType(); 
     66        final int c = outputImp.getNChannels(); 
     67        final int z = outputImp.getNSlices(); 
     68        final int t = outputImp.getNFrames(); 
    6369 
    64         if (wj == wk && hj == hk && tj == tk) { 
    65           ImagePlus oldImp = newImps.get(k); 
    66           ImageStack is = oldImp.getStack(); 
    67           ImageStack newStack = imp.getStack(); 
    68           for (int s=0; s<newStack.getSize(); s++) { 
    69             is.addSlice(newStack.getSliceLabel(s + 1), 
    70               newStack.getProcessor(s + 1)); 
    71           } 
    72           oldImp.setStack(oldImp.getTitle(), is); 
    73           newImps.set(k, oldImp); 
    74           append = true; 
    75           k = widths.size(); 
     70        // verify that images are compatible 
     71        if (width != w || height != h) continue; // different XY resolution 
     72        if (type != outType) continue; // different processor type 
     73        final boolean canAppendT = cSize == c && zSize == z; 
     74        final boolean canAppendZ = cSize == c && tSize == t; 
     75        final boolean canAppendC = zSize == z && tSize == t; 
     76        if (!canAppendT && !canAppendZ && !canAppendC) { 
     77          // incompatible dimensions 
     78          continue; 
    7679        } 
     80 
     81        // concatenate planes onto this output image 
     82        final ImageStack outputStack = outputImp.getStack(); 
     83        final ImageStack inputStack = imp.getStack(); 
     84        for (int s=0; s<inputStack.getSize(); s++) { 
     85          outputStack.addSlice(inputStack.getSliceLabel(s + 1), 
     86            inputStack.getProcessor(s + 1)); 
     87        } 
     88        outputImp.setStack(outputImp.getTitle(), outputStack); 
     89 
     90        // update image dimensions 
     91        // NB: For now, we prioritize adding to the time points, then 
     92        // focal planes, and lastly channels. In some cases, there may be 
     93        // multiple compatible dimensions; in the future, we may prompt the 
     94        // user to choose the axis for concatenation. 
     95        if (canAppendT) outputImp.setDimensions(c, z, t + tSize); 
     96        else if (canAppendZ) outputImp.setDimensions(c, z + zSize, t); 
     97        else if (canAppendC) outputImp.setDimensions(c + cSize, z, t); 
     98        else throw new IllegalStateException("Dimensional mismatch"); 
     99 
     100        append = true; 
     101        break;         
    77102      } 
    78103      if (!append) { 
    79         widths.add(new Integer(wj)); 
    80         heights.add(new Integer(hj)); 
    81         types.add(new Integer(tj)); 
    82         newImps.add(imp); 
     104        // could not concatenate input image to any existing output; 
     105        // append it to the list of outputs directly instead 
     106        outputImps.add(imp); 
    83107      } 
    84108    } 
    85109 
    86     return newImps; 
     110    return outputImps; 
    87111  } 
    88112 
  • branches/4.2/components/loci-plugins/src/loci/plugins/in/ImportProcess.java

    r6564 r6584  
    4444import loci.formats.FileStitcher; 
    4545import loci.formats.FormatException; 
    46 import loci.formats.FormatTools; 
    4746import loci.formats.IFormatReader; 
    4847import loci.formats.ImageReader; 
  • branches/4.2/components/loci-plugins/src/loci/plugins/in/importer-options.txt

    r6341 r6584  
    4444  <br><br>Possible choices are:<ul>                                      \ 
    4545  <li><b>Default</b> - Display channels as closely as possible           \ 
    46   to how they are stored in the file. For 8-bit indexed color,           \ 
    47   this is the only choice that will preserve the index values.</li>      \ 
     46  to how they are stored in the file.</li>                               \ 
    4847  <li><b>Composite</b> - Open as a merged composite image. Channels are  \ 
    4948  colorized according to metadata present in the dataset (if any),       \ 
     
    5958  </ul>                                                                  \ 
    6059  Note that ImageJ can only composite together 7 or fewer channels.      \ 
    61   With more than 7 channels, Bio-Formats will ask how to split them up.  \ 
    62   For example, a 12-channel dataset could be partitioned as:<ul>         \ 
    63   <li>6 planes with 2 channels each</li>                                 \ 
    64   <li>4 planes with 3 channels each</li>                                 \ 
    65   <li>3 planes with 4 channels each</li>                                 \ 
    66   <li>3 planes with 5 channels each</li>                                 \ 
    67   <li>2 planes with 6 channels each</li>                                 \ 
    68   <li>2 planes with 7 channels each</li>                                 \ 
    69   </ul> 
     60  With more than 7 channels, some of the modes above may not work. 
    7061default = Default 
    7162values = \ 
  • branches/4.2/components/loci-plugins/src/loci/plugins/util/ImagePlusTools.java

    r6555 r6584  
    2626package loci.plugins.util; 
    2727 
    28 import ij.CompositeImage; 
    2928import ij.ImagePlus; 
    3029import ij.ImageStack; 
    3130import ij.measure.Calibration; 
    32 import ij.process.ByteProcessor; 
    3331import ij.process.ColorProcessor; 
    34 import ij.process.FloatProcessor; 
    3532import ij.process.ImageProcessor; 
    36 import ij.process.ShortProcessor; 
    3733 
    3834import java.io.IOException; 
     
    5753 
    5854  // -- Utility methods -- 
    59  
    60   /** 
    61    * Converts the given array of ImageProcessors into a single-slice 
    62    * RGB ImagePlus. 
    63    */ 
    64 /* FIXME remove makeRGB methods 
    65   public static ImagePlus makeRGB(ImageProcessor[] p) { 
    66     return makeRGB("", p); 
    67   } 
    68 */ 
    69  
    70   /** 
    71    * Converts the given array of ImageProcessors into a single-slice 
    72    * RGB ImagePlus. 
    73    */ 
    74 /* FIXME remove makeRGB methods 
    75   public static ImagePlus makeRGB(String title, ImageProcessor[] p) { 
    76     if (p.length == 1) return new ImagePlus(title, p[0]); 
    77  
    78     // check that all processors are of the same type and size 
    79     boolean sameType = true; 
    80     int width = p[0].getWidth(); 
    81     int height = p[0].getHeight(); 
    82     boolean byteProc = p[0] instanceof ByteProcessor; 
    83     boolean shortProc = p[0] instanceof ShortProcessor; 
    84     boolean floatProc = p[0] instanceof FloatProcessor; 
    85     for (int i=1; i<p.length; i++) { 
    86       int w = p[i].getWidth(); 
    87       int h = p[i].getHeight(); 
    88       boolean b = p[i] instanceof ByteProcessor; 
    89       boolean s = p[i] instanceof ShortProcessor; 
    90       boolean f = p[i] instanceof FloatProcessor; 
    91       if (w != width || h != height || b != byteProc || s != shortProc || 
    92         f != floatProc) 
    93       { 
    94         sameType = false; 
    95         break; 
    96       } 
    97     } 
    98  
    99     if (!sameType || p.length > 4 || p[0] instanceof ColorProcessor) { 
    100       return null; 
    101     } 
    102  
    103     ImagePlus imp = null; 
    104  
    105     if (p.length < 4 && byteProc) { 
    106       ColorProcessor cp = new ColorProcessor(width, height); 
    107       byte[][] bytes = new byte[p.length][]; 
    108       for (int i=0; i<p.length; i++) { 
    109         bytes[i] = (byte[]) p[i].getPixels(); 
    110       } 
    111       cp.setRGB(bytes[0], bytes[1], bytes.length == 3 ? bytes[2] : 
    112         new byte[width * height]); 
    113       imp = new ImagePlus(title, cp); 
    114     } 
    115     else if (p.length <= 7) { 
    116       ImageStack tmpStack = new ImageStack(width, height); 
    117       for (int i=0; i<p.length; i++) tmpStack.addSlice("", p[i]); 
    118  
    119       ImagePlus ii = new ImagePlus(title, tmpStack); 
    120       imp = new CompositeImage(ii, CompositeImage.COMPOSITE); 
    121     } 
    122  
    123     return imp; 
    124   } 
    125 */ 
    12655 
    12756  /** Applies spatial calibrations to an image stack. */ 
     
    16897    int pixelType = FormatTools.pixelTypeFromString(type); 
    16998 
     99    // NB: INT32 is represented with FloatProcessor, so no need to calibrate. 
    170100    boolean signed = pixelType == FormatTools.INT8 || 
    171       pixelType == FormatTools.INT16 || pixelType == FormatTools.INT32; 
     101      pixelType == FormatTools.INT16; // || pixelType == FormatTools.INT32; 
    172102 
    173103    // set calibration function, so that both signed and unsigned pixel 
Note: See TracChangeset for help on using the changeset viewer.