Changeset 7453


Ignore:
Timestamp:
12/23/10 10:48:14 (9 years ago)
Author:
melissa
Message:

Added methods for retrieving the optimal size of a sub-image. Closes #599.

Location:
trunk/components/bio-formats/src/loci/formats
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/FormatReader.java

    r7038 r7453  
    10441044  } 
    10451045 
     1046  /* @see IFormatReader#getOptimalTileWidth() */ 
     1047  public int getOptimalTileWidth() { 
     1048    FormatTools.assertId(currentId, true, 1); 
     1049    return getSizeX(); 
     1050  } 
     1051 
     1052  /* @see IFormatReader#getOptimalTileHeight() */ 
     1053  public int getOptimalTileHeight() { 
     1054    FormatTools.assertId(currentId, true, 1); 
     1055    return 1; 
     1056  } 
     1057 
    10461058  // -- IFormatHandler API methods -- 
    10471059 
  • trunk/components/bio-formats/src/loci/formats/IFormatReader.java

    r6881 r7453  
    471471  boolean hasCompanionFiles(); 
    472472 
     473  /** Returns the optimal sub-image width for use with openBytes. */ 
     474  int getOptimalTileWidth(); 
     475 
     476  /** Returns the optimal sub-image height for use with openBytes. */ 
     477  int getOptimalTileHeight(); 
     478 
    473479  // -- Deprecated methods -- 
    474480 
  • trunk/components/bio-formats/src/loci/formats/ImageReader.java

    r6881 r7453  
    614614  } 
    615615 
     616  /* @see IFormatReader#getOptimalTileWidth() */ 
     617  public int getOptimalTileWidth() { 
     618    return getReader().getOptimalTileWidth(); 
     619  } 
     620 
     621  /* @see IFormatReader#getOptimalTileHeight() */ 
     622  public int getOptimalTileHeight() { 
     623    return getReader().getOptimalTileHeight(); 
     624  } 
     625 
    616626  // -- IFormatHandler API methods -- 
    617627 
  • trunk/components/bio-formats/src/loci/formats/ReaderWrapper.java

    r6881 r7453  
    457457  public String[] getDomains() { 
    458458    return reader.getDomains(); 
     459  } 
     460 
     461  public int getOptimalTileWidth() { 
     462    return reader.getOptimalTileWidth(); 
     463  } 
     464 
     465  public int getOptimalTileHeight() { 
     466    return reader.getOptimalTileHeight(); 
    459467  } 
    460468 
  • trunk/components/bio-formats/src/loci/formats/in/APLReader.java

    r6881 r7453  
    145145  } 
    146146 
     147  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     148  public int getOptimalTileWidth() { 
     149    FormatTools.assertId(currentId, true, 1); 
     150    return tiffReaders[getSeries()].getOptimalTileWidth(); 
     151  } 
     152 
     153  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     154  public int getOptimalTileHeight() { 
     155    FormatTools.assertId(currentId, true, 1); 
     156    return tiffReaders[getSeries()].getOptimalTileHeight(); 
     157  } 
     158 
    147159  // -- Internal FormatReader API methods -- 
    148160 
  • trunk/components/bio-formats/src/loci/formats/in/BDReader.java

    r7122 r7453  
    178178      reader.setId(file); 
    179179      reader.openBytes(0, buf, x, y, w, h); 
    180       reader.close(); 
    181180    } 
    182181 
    183182    return buf; 
     183  } 
     184 
     185  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     186  public int getOptimalTileWidth() { 
     187    FormatTools.assertId(currentId, true, 1); 
     188    return reader.getOptimalTileWidth(); 
     189  } 
     190 
     191  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     192  public int getOptimalTileHeight() { 
     193    FormatTools.assertId(currentId, true, 1); 
     194    return reader.getOptimalTileHeight(); 
    184195  } 
    185196 
     
    247258    boolean indexed = reader.isIndexed(); 
    248259    boolean littleEndian = reader.isLittleEndian(); 
    249  
    250     reader.close(); 
    251260 
    252261    if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { 
  • trunk/components/bio-formats/src/loci/formats/in/InCellReader.java

    r7418 r7453  
    237237  } 
    238238 
     239  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     240  public int getOptimalTileWidth() { 
     241    FormatTools.assertId(currentId, true, 1); 
     242    if (imageFiles[0][0][0][0].isTiff) { 
     243      return tiffReader.getOptimalTileWidth(); 
     244    } 
     245    return super.getOptimalTileWidth(); 
     246  } 
     247 
     248  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     249  public int getOptimalTileHeight() { 
     250    FormatTools.assertId(currentId, true, 1); 
     251    if (imageFiles[0][0][0][0].isTiff) { 
     252      return tiffReader.getOptimalTileHeight(); 
     253    } 
     254    return super.getOptimalTileHeight(); 
     255  } 
     256 
    239257  // -- Internal FormatReader API methods -- 
    240258 
  • trunk/components/bio-formats/src/loci/formats/in/L2DReader.java

    r7071 r7453  
    6262 
    6363  private MinimalTiffReader reader; 
     64  private int[] tileWidth, tileHeight; 
    6465 
    6566  // -- Constructor -- 
     
    154155      reader = null; 
    155156      metadataFiles = null; 
    156     } 
     157      tileWidth = null; 
     158      tileHeight = null; 
     159    } 
     160  } 
     161 
     162  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     163  public int getOptimalTileWidth() { 
     164    FormatTools.assertId(currentId, true, 1); 
     165    return tileWidth[getSeries()]; 
     166  } 
     167 
     168  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     169  public int getOptimalTileHeight() { 
     170    FormatTools.assertId(currentId, true, 1); 
     171    return tileHeight[getSeries()]; 
    157172  } 
    158173 
     
    223238    String model = null; 
    224239 
     240    tileWidth = new int[scans.length]; 
     241    tileHeight = new int[scans.length]; 
     242 
    225243    for (int i=0; i<scans.length; i++) { 
    226244      setSeries(i); 
     
    289307      core[i].littleEndian = reader.isLittleEndian(); 
    290308      core[i].pixelType = reader.getPixelType(); 
     309      tileWidth[i] = reader.getOptimalTileWidth(); 
     310      tileHeight[i] = reader.getOptimalTileHeight(); 
    291311    } 
    292312 
  • trunk/components/bio-formats/src/loci/formats/in/LeicaReader.java

    r7451 r7453  
    166166 
    167167  private Double detectorOffset, detectorVoltage; 
     168 
     169  private int[] tileWidth, tileHeight; 
    168170 
    169171  // -- Constructor -- 
     
    333335  } 
    334336 
     337  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     338  public int getOptimalTileWidth() { 
     339    FormatTools.assertId(currentId, true, 1); 
     340    return tileWidth[getSeries()]; 
     341  } 
     342 
     343  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     344  public int getOptimalTileHeight() { 
     345    FormatTools.assertId(currentId, true, 1); 
     346    return tileHeight[getSeries()]; 
     347  } 
     348 
    335349  // -- Internal FormatReader API methods -- 
    336350 
     
    423437 
    424438    numSeries = headerIFDs.size(); 
     439 
     440    tileWidth = new int[numSeries]; 
     441    tileHeight = new int[numSeries]; 
    425442 
    426443    core = new CoreMetadata[numSeries]; 
     
    558575      core[i].sizeX = tiff.getSizeX(); 
    559576      core[i].sizeY = tiff.getSizeY(); 
     577      tileWidth[i] = tiff.getOptimalTileWidth(); 
     578      tileHeight[i] = tiff.getOptimalTileHeight(); 
    560579    } 
    561580 
  • trunk/components/bio-formats/src/loci/formats/in/MIASReader.java

    r7140 r7453  
    286286      overlayPlanes.clear(); 
    287287    } 
     288  } 
     289 
     290  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     291  public int getOptimalTileWidth() { 
     292    FormatTools.assertId(currentId, true, 1); 
     293    return readers[0][0].getOptimalTileWidth(); 
     294  } 
     295 
     296  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     297  public int getOptimalTileHeight() { 
     298    FormatTools.assertId(currentId, true, 1); 
     299    return readers[0][0].getOptimalTileHeight(); 
    288300  } 
    289301 
  • trunk/components/bio-formats/src/loci/formats/in/MicromanagerReader.java

    r6881 r7453  
    179179  } 
    180180 
     181  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     182  public int getOptimalTileWidth() { 
     183    FormatTools.assertId(currentId, true, 1); 
     184    return tiffReader.getOptimalTileWidth(); 
     185  } 
     186 
     187  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     188  public int getOptimalTileHeight() { 
     189    FormatTools.assertId(currentId, true, 1); 
     190    return tiffReader.getOptimalTileWidth(); 
     191  } 
     192 
    181193  // -- Internal FormatReader API methods -- 
    182194 
  • trunk/components/bio-formats/src/loci/formats/in/MinimalTiffReader.java

    r6881 r7453  
    277277      tiffParser = null; 
    278278    } 
     279  } 
     280 
     281  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     282  public int getOptimalTileWidth() { 
     283    FormatTools.assertId(currentId, true, 1); 
     284    try { 
     285      return (int) ifds.get(0).getTileWidth(); 
     286    } 
     287    catch (FormatException e) { 
     288      LOGGER.debug("Could not retrieve tile width", e); 
     289    } 
     290    return super.getOptimalTileWidth(); 
     291  } 
     292 
     293  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     294  public int getOptimalTileHeight() { 
     295    FormatTools.assertId(currentId, true, 1); 
     296    try { 
     297      return (int) ifds.get(0).getTileLength(); 
     298    } 
     299    catch (FormatException e) { 
     300      LOGGER.debug("Could not retrieve tile height", e); 
     301    } 
     302    return super.getOptimalTileHeight(); 
    279303  } 
    280304 
  • trunk/components/bio-formats/src/loci/formats/in/OMETiffReader.java

    r7402 r7453  
    7777  private boolean hasSPW; 
    7878 
     79  private int[] tileWidth; 
     80  private int[] tileHeight; 
     81 
    7982  private OMEXMLService service; 
    8083 
     
    232235      used = null; 
    233236      lastPlane = 0; 
    234     } 
     237      tileWidth = null; 
     238      tileHeight = null; 
     239    } 
     240  } 
     241 
     242  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     243  public int getOptimalTileWidth() { 
     244    FormatTools.assertId(currentId, true, 1); 
     245    return tileWidth[getSeries()]; 
     246  } 
     247 
     248  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     249  public int getOptimalTileHeight() { 
     250    FormatTools.assertId(currentId, true, 1); 
     251    return tileHeight[getSeries()]; 
    235252  } 
    236253 
     
    288305    } 
    289306    info = new OMETiffPlane[seriesCount][]; 
     307 
     308    tileWidth = new int[seriesCount]; 
     309    tileHeight = new int[seriesCount]; 
    290310 
    291311    // compile list of file/UUID mappings 
     
    539559      info[s] = planes; 
    540560      try { 
     561        info[s][0].reader.setId(info[s][0].id); 
     562        tileWidth[s] = info[s][0].reader.getOptimalTileWidth(); 
     563        tileHeight[s] = info[s][0].reader.getOptimalTileHeight(); 
     564 
    541565        core[s].sizeX = meta.getPixelsSizeX(i).getValue().intValue(); 
    542566        int tiffWidth = (int) firstIFD.getImageWidth(); 
  • trunk/components/bio-formats/src/loci/formats/in/PerkinElmerReader.java

    r7090 r7453  
    239239      originX = originY = originZ = 0f; 
    240240    } 
     241  } 
     242 
     243  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     244  public int getOptimalTileWidth() { 
     245    FormatTools.assertId(currentId, true, 1); 
     246    if (isTiff) { 
     247      return tiff.getOptimalTileWidth(); 
     248    } 
     249    return super.getOptimalTileWidth(); 
     250  } 
     251 
     252  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     253  public int getOptimalTileHeight() { 
     254    FormatTools.assertId(currentId, true, 1); 
     255    if (isTiff) { 
     256      return tiff.getOptimalTileHeight(); 
     257    } 
     258    return super.getOptimalTileHeight(); 
    241259  } 
    242260 
  • trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java

    r6967 r7453  
    8080  private Double pixelSize; 
    8181 
     82  private int tileWidth = 0; 
     83  private int tileHeight = 0; 
     84 
    8285  private String[] tiffs; 
    8386  private MinimalTiffReader reader; 
     
    178181      wellCount = 0; 
    179182      pixelSize = null; 
     183      tileWidth = 0; 
     184      tileHeight = 0; 
    180185    } 
    181186  } 
     
    211216 
    212217    return buf; 
     218  } 
     219 
     220  /* @see loci.formats.IFormatReader#getOptimalTileWidth() */ 
     221  public int getOptimalTileWidth() { 
     222    FormatTools.assertId(currentId, true, 1); 
     223    return tileWidth; 
     224  } 
     225 
     226  /* @see loci.formats.IFormatReader#getOptimalTileHeight() */ 
     227  public int getOptimalTileHeight() { 
     228    FormatTools.assertId(currentId, true, 1); 
     229    return tileHeight; 
    213230  } 
    214231 
     
    394411    int sizeY = reader.getSizeY(); 
    395412    int pixelType = reader.getPixelType(); 
     413 
     414    tileWidth = reader.getOptimalTileWidth(); 
     415    tileHeight = reader.getOptimalTileHeight(); 
    396416 
    397417    // we strongly suspect that ScanR incorrectly records the 
Note: See TracChangeset for help on using the changeset viewer.