Changeset 6433


Ignore:
Timestamp:
06/01/10 14:11:49 (9 years ago)
Author:
curtis
Message:

Fix intensity scaling issue with signed and float pixel types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/src/loci/plugins/in/ImagePlusReader.java

    r6385 r6433  
    140140 
    141141    if (options.isVirtual()) { 
     142      // set virtual stack's reference count to match # of image windows 
     143      // in this case, these is one window per enabled image series 
     144      // when all image windows are closed, the Bio-Formats reader is closed 
    142145      int totalSeries = 0; 
    143146      for (int s=0; s<reader.getSeriesCount(); s++) { 
     
    147150    } 
    148151 
     152    // read in each image series 
    149153    for (int s=0; s<reader.getSeriesCount(); s++) { 
    150154      if (!options.isSeriesOn(s)) continue; 
     
    463467    imp.setOpenAsHyperStack(true); 
    464468 
    465     if (options.isAutoscale()) { 
     469    // apply intensity scaling 
     470    int pixelType = reader.getPixelType(); 
     471    // always autoscale floating point image data 
     472    if (options.isAutoscale() || FormatTools.isFloatingPoint(pixelType)) { 
    466473      ImagePlusTools.adjustColorRange(imp, process.getMinMaxCalculator()); 
    467474    } 
    468     else if (!(imp.getProcessor() instanceof FloatProcessor)) { 
    469       // ImageJ may autoscale the images anyway, so we need to manually 
    470       // set the display range to the min/max values allowed for 
    471       // this pixel type 
    472       imp.setDisplayRange(0, Math.pow(2, imp.getBitDepth()) - 1); 
     475    else { 
     476      // ImageJ may autoscale the images anyway, so we need to manually set 
     477      // the display range to the min/max values allowed for this pixel type 
     478      int bitDepth = reader.getBitsPerPixel(); 
     479      // NB: ImageJ does not directly support signed data (it is merely 
     480      // unsigned data shifted downward by half via a "calibration"), 
     481      // so the following min and max values also work for signed. 
     482      double min = 0; 
     483      double max = Math.pow(2, bitDepth) - 1; 
     484      imp.setDisplayRange(min, max); 
    473485    } 
    474486 
Note: See TracChangeset for help on using the changeset viewer.