Changeset 3139


Ignore:
Timestamp:
09/06/07 10:51:05 (12 years ago)
Author:
melissa
Message:

Finished indexed color logic.

Location:
trunk/loci
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FileStitcher.java

    r3131 r3139  
    288288 
    289289  /* @see IFormatReader#get8BitLookupTable() */ 
    290   public byte[][] get8BitLookupTable() throws FormatException { 
     290  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    291291    FormatTools.assertId(currentId, true, 2); 
    292292    return reader.get8BitLookupTable(); 
     
    294294 
    295295  /* @see IFormatReader#get16BitLookupTable() */ 
    296   public short[][] get16BitLookupTable() throws FormatException { 
     296  public short[][] get16BitLookupTable() throws FormatException, IOException { 
    297297    FormatTools.assertId(currentId, true, 2); 
    298298    return reader.get16BitLookupTable(); 
  • trunk/loci/formats/FormatReader.java

    r3131 r3139  
    253253 
    254254  /* @see IFormatReader#get8BitLookupTable() */ 
    255   public byte[][] get8BitLookupTable() throws FormatException { 
     255  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    256256    return null; 
    257257  } 
    258258 
    259259  /* @see IFormatReader#get16BitLookupTable() */ 
    260   public short[][] get16BitLookupTable() throws FormatException { 
     260  public short[][] get16BitLookupTable() throws FormatException, IOException { 
    261261    return null; 
    262262  } 
  • trunk/loci/formats/IFormatReader.java

    r3131 r3139  
    9898   * <code>INT8</code> or <code>UINT8</code>, this method will return null. 
    9999   */ 
    100   byte[][] get8BitLookupTable() throws FormatException; 
     100  byte[][] get8BitLookupTable() throws FormatException, IOException; 
    101101 
    102102  /** 
     
    107107   * <code>INT8</code> or <code>UINT8</code>, this method will return null. 
    108108   */ 
    109   short[][] get16BitLookupTable() throws FormatException; 
     109  short[][] get16BitLookupTable() throws FormatException, IOException; 
    110110 
    111111  /** 
  • trunk/loci/formats/ImageReader.java

    r3137 r3139  
    238238 
    239239  /* @see IFormatReader#get8BitLookupTable() */ 
    240   public byte[][] get8BitLookupTable() throws FormatException { 
     240  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    241241    FormatTools.assertId(currentId, true, 2); 
    242242    return getReader().get8BitLookupTable(); 
     
    244244 
    245245  /* @see IFormatReader#get16BitLookupTable() */ 
    246   public short[][] get16BitLookupTable() throws FormatException { 
     246  public short[][] get16BitLookupTable() throws FormatException, IOException { 
    247247    FormatTools.assertId(currentId, true, 2); 
    248248    return getReader().get16BitLookupTable(); 
  • trunk/loci/formats/ReaderWrapper.java

    r3131 r3139  
    122122  } 
    123123 
    124   public byte[][] get8BitLookupTable() throws FormatException { 
     124  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    125125    return reader.get8BitLookupTable(); 
    126126  } 
    127127 
    128   public short[][] get16BitLookupTable() throws FormatException { 
     128  public short[][] get16BitLookupTable() throws FormatException, IOException { 
    129129    return reader.get16BitLookupTable(); 
    130130  } 
  • trunk/loci/formats/doc/samples-needed.txt

    r3009 r3139  
    7474 
    7575Zeiss ZVI: 
    76   - JPEG compressed  
     76  - JPEG compressed 
     77  - tiled 
    7778  - 2+ GB files 
  • trunk/loci/formats/in/AVIReader.java

    r3131 r3139  
    106106 
    107107  /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
    108   public byte[][] get8BitLookupTable() throws FormatException { 
     108  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    109109    FormatTools.assertId(currentId, true, 1); 
    110110    return new byte[][] {pr, pg, pb}; 
  • trunk/loci/formats/in/BMPReader.java

    r3132 r3139  
    9393 
    9494  /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
    95   public byte[][] get8BitLookupTable() throws FormatException { 
     95  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    9696    FormatTools.assertId(currentId, true, 1); 
    9797    return palette;  
  • trunk/loci/formats/in/BaseTiffReader.java

    r3131 r3139  
    8888 
    8989  /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
    90   public byte[][] get8BitLookupTable() throws FormatException { 
     90  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    9191    FormatTools.assertId(currentId, true, 1);   
    9292    int[] bits = TiffTools.getBitsPerSample(ifds[0]); 
     
    9494      int[] colorMap =  
    9595        (int[]) TiffTools.getIFDValue(ifds[0], TiffTools.COLOR_MAP); 
     96       
    9697      byte[][] table = new byte[3][colorMap.length / 3]; 
    9798      int next = 0;  
    9899      for (int j=0; j<table.length; j++) { 
    99100        for (int i=0; i<table[0].length; i++) { 
    100           if (core.littleEndian[0]) { 
    101             table[j][i] = (byte) (colorMap[next++] & 0xff); 
     101          if (isLittleEndian()) { 
     102            int n = colorMap[next++]; 
     103            if ((n & 0xffff) > 255) table[j][i] = (byte) ((n & 0xff00) >> 8); 
     104            else table[j][i] = (byte) (n & 0xff); 
    102105          } 
    103106          else table[j][i] = (byte) ((colorMap[next++] & 0xff00) >> 8); 
     
    111114 
    112115  /* @see loci.formats.IFormatReader#get16BitLookupTable() */ 
    113   public short[][] get16BitLookupTable() throws FormatException { 
     116  public short[][] get16BitLookupTable() throws FormatException, IOException { 
    114117    FormatTools.assertId(currentId, true, 1);   
    115118    int[] bits = TiffTools.getBitsPerSample(ifds[0]);  
  • trunk/loci/formats/in/GIFReader.java

    r3132 r3139  
    122122 
    123123  /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
    124   public byte[][] get8BitLookupTable() throws FormatException { 
     124  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    125125    FormatTools.assertId(currentId, true, 1);  
    126126    byte[][] table = new byte[3][act.length]; 
  • trunk/loci/formats/in/KhorosReader.java

    r3131 r3139  
    6565 
    6666  /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
    67   public byte[][] get8BitLookupTable() throws FormatException { 
     67  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
    6868    FormatTools.assertId(currentId, true, 1); 
    6969    byte[][] table = new byte[3][lut.length / 3]; 
  • trunk/loci/formats/in/LeicaReader.java

    r3106 r3139  
    6363  private int numSeries; 
    6464 
    65   /** Number of significant bits per pixel. */ 
    66   private int[][] validBits; 
    67  
    68   private int[] channelIndices; 
    69  
    7065  /** Name of current LEI file */ 
    7166  private String leiFilename; 
     
    112107  } 
    113108 
     109  /* @see loci.formats.IFormatReader#isIndexed() */ 
     110  public boolean isIndexed() { 
     111    return true;  
     112  } 
     113 
     114  /* @see loci.formats.IFormatReader#get8BitLookupTable() */ 
     115  public byte[][] get8BitLookupTable() throws FormatException, IOException { 
     116    FormatTools.assertId(currentId, true, 1); 
     117    tiff[0][0].setId((String) files[0].get(0));  
     118    return tiff[0][0].get8BitLookupTable();  
     119  } 
     120 
     121  /* @see loci.formats.IFormatReader#get16BitLookupTable() */ 
     122  public short[][] get16BitLookupTable() throws FormatException, IOException { 
     123    FormatTools.assertId(currentId, true, 1); 
     124    tiff[0][0].setId((String) files[0].get(0));  
     125    return tiff[0][0].get16BitLookupTable();  
     126  } 
     127 
    114128  /* @see loci.formats.IFormatReader#isMetadataComplete() */ 
    115129  public boolean isMetadataComplete() { 
     
    129143      throw new FormatException("Invalid image number: " + no); 
    130144    } 
    131     int ndx = no % channelIndices.length; 
    132145    tiff[series][no].setId((String) files[series].get(no)); 
    133146    byte[] b = tiff[series][no].openBytes(0); 
    134  
    135     int c = b.length / (core.sizeX[series] * core.sizeY[series] * 
    136       FormatTools.getBytesPerPixel(core.pixelType[series])); 
    137  
    138     // if a custom LUT is used, we don't want to split channels 
    139     if (channelIndices[ndx] > -1) { 
    140       b = ImageTools.splitChannels(b, c, 
    141         FormatTools.getBytesPerPixel(core.pixelType[series]), false, 
    142         isInterleaved())[channelIndices[ndx]]; 
    143     } 
    144     tiff[series][no].close(); 
     147    tiff[series][no].close();  
    145148    return b; 
    146149  } 
     
    157160    tiff[series][no].openBytes(0, buf); 
    158161    tiff[series][no].close(); 
    159  
    160     int ndx = no % channelIndices.length; 
    161     int c = buf.length / (core.sizeX[series] * core.sizeY[series] * 
    162       FormatTools.getBytesPerPixel(core.pixelType[series])); 
    163  
    164     // if a custom LUT is used, we don't want to split channels 
    165     if (channelIndices[ndx] > -1) { 
    166       buf = ImageTools.splitChannels(buf, c, 
    167         FormatTools.getBytesPerPixel(core.pixelType[series]), false, 
    168         isInterleaved())[channelIndices[ndx]]; 
    169     } 
    170162    return buf; 
    171163  } 
     
    180172    tiff[series][no].setId((String) files[series].get(no)); 
    181173    BufferedImage b = tiff[series][no].openImage(0); 
    182  
    183     int ndx = no % channelIndices.length; 
    184  
    185     // if a custom LUT is used, we don't want to split channels 
    186     if (channelIndices[ndx] > -1) { 
    187       b = ImageTools.splitChannels(b)[channelIndices[ndx]]; 
    188     } 
    189174    tiff[series][no].close(); 
    190175    return b; 
     
    486471          prefix = DataTools.stripString(new String(tempData, 
    487472            20 + 2*(j*nameLength), 2*nameLength)); 
    488           f.add(dirPrefix + prefix); 
     473          f.add(dirPrefix + File.separator + prefix); 
    489474          // test to make sure the path is valid 
    490475          Location test = new Location((String) f.get(f.size() - 1)); 
     
    978963        if (nChannels > 4) nChannels = 3; 
    979964        core.sizeC[i] = nChannels; 
    980         channelIndices = new int[nChannels]; 
    981965 
    982966        for (int j=0; j<nChannels; j++) { 
     
    1006990 
    1007991          String name = DataTools.stripString(new String(temp, pt, length)); 
    1008  
    1009           if (name.equals("Red")) channelIndices[j] = 0; 
    1010           else if (name.equals("Green")) channelIndices[j] = 1; 
    1011           else if (name.equals("Blue")) channelIndices[j] = 2; 
    1012           else if (name.equals("Gray")) channelIndices[j] = 0; 
    1013           else if (name.equals("Yellow")) channelIndices[j] = 0; 
    1014           else { 
    1015             // using a custom LUT 
    1016             channelIndices[j] = -1; 
    1017           } 
    1018992 
    1019993          addMeta("LUT Channel " + j + " name", name); 
     
    10411015 
    10421016    Integer v = (Integer) getMeta("Real world resolution"); 
    1043  
    1044     if (v != null) { 
    1045       validBits = new int[core.sizeC.length][]; 
    1046  
    1047       for (int i=0; i<validBits.length; i++) { 
    1048         validBits[i] = new int[core.sizeC[i] == 2 ? 3 : core.sizeC[i]]; 
    1049         for (int j=0; j<validBits[i].length; j++) { 
    1050           validBits[i][j] = v.intValue(); 
    1051         } 
    1052       } 
    1053     } 
    1054     else validBits = null; 
    10551017 
    10561018    // the metadata store we're working with 
     
    10991061      Integer ii = new Integer(i); 
    11001062 
    1101       // if a custom LUT is used, we don't want to split channels 
    1102       if (channelIndices[0] == -1) { 
    1103         core.sizeC[i] *= 3; 
    1104         core.rgb[i] = true; 
    1105       } 
     1063      core.rgb[i] = true; 
     1064      core.sizeC[i] *= 3; 
    11061065 
    11071066      store.setPixels( 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r3134 r3139  
    483483      pixZ == null ? null : new Float(pixZ), 
    484484      null, null, null); 
     485 
     486    String scopeName = (String) getMeta("Microscope Name"); 
     487    if (scopeName == null) scopeName = (String) getMeta("Microscope Name 0"); 
     488    store.setInstrument(null, scopeName, null, null, null); 
    485489 
    486490    for (int i=0; i<getEffectiveSizeC(); i++) { 
  • trunk/loci/plugins/Importer.java

    r3110 r3139  
    696696    int pixelType = r.getPixelType(); 
    697697    if (mergeChannels && r.getSizeC() > 1 && r.getSizeC() < 4 && 
    698       (pixelType == FormatTools.UINT8 || pixelType == FormatTools.INT8)) 
     698      (pixelType == FormatTools.UINT8 || pixelType == FormatTools.INT8) && 
     699      !r.isIndexed()) 
    699700    { 
    700701      makeRGB(imp, r, r.getSizeC()); 
    701702    } 
    702     else if (mergeChannels && r.getSizeC() > 1 && r.getSizeC() < 4) { 
     703    else if (mergeChannels && r.getSizeC() > 1 && r.getSizeC() < 4 && 
     704      !r.isIndexed())  
     705    { 
    703706      // use compareTo instead of IJ.versionLessThan(...), because we want 
    704707      // to suppress the error message 
  • trunk/loci/plugins/Util.java

    r3015 r3139  
    3030import ij.process.*; 
    3131import java.awt.*; 
    32 import java.awt.image.BufferedImage; 
     32import java.awt.image.*; 
    3333import java.io.IOException; 
    3434import loci.formats.*; 
     
    112112      r.isLittleEndian()); 
    113113 
     114    IndexColorModel cm = null; 
     115    IndexedColorModel model = null; 
     116    if (r.isIndexed()) { 
     117      byte[][] byteTable = r.get8BitLookupTable(); 
     118      if (byteTable != null) { 
     119        cm = new IndexColorModel(8, byteTable[0].length, byteTable[0], 
     120          byteTable[1], byteTable[2]); 
     121      } 
     122      else { 
     123        short[][] shortTable = r.get16BitLookupTable(); 
     124        model = new IndexedColorModel(16, shortTable[0].length, shortTable);  
     125      } 
     126    } 
     127 
    114128    // construct image processor 
    115129    ImageProcessor ip = null; 
     
    122136      } 
    123137      ip = new ByteProcessor(w, h, q, null); 
     138      if (cm != null) ip.setColorModel(cm);  
    124139    } 
    125140    else if (pixels instanceof short[]) { 
     
    130145        System.arraycopy(tmp, 0, q, 0, q.length); 
    131146      } 
    132       ip = new ShortProcessor(w, h, q, null); 
     147      ip = new ShortProcessor(w, h, q, model); 
    133148    } 
    134149    else if (pixels instanceof int[]) { 
Note: See TracChangeset for help on using the changeset viewer.