Changeset 2624


Ignore:
Timestamp:
04/16/07 10:02:34 (13 years ago)
Author:
melissa
Message:

Fixed bug with how updateMinMax(byte[], int) converts bytes to doubles. Also
fixed a bug with min/max calculation on RGB images.

File:
1 edited

Legend:

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

    r2601 r2624  
    201201    initMinMax(); 
    202202 
     203    int numRGB = getRGBChannelCount(); 
     204 
    203205    // check whether min/max values have already been computed for this plane 
    204     if (planeMin[getSeries()][ndx] == planeMin[getSeries()][ndx]) return; 
     206    if (planeMin[getSeries()][ndx * numRGB] ==  
     207      planeMin[getSeries()][ndx * numRGB])  
     208    { 
     209      return; 
     210    } 
    205211 
    206212    int[] coords = getZCTCoords(ndx); 
    207     int numRGB = getRGBChannelCount(); 
    208213    int cBase = coords[1] * numRGB; 
    209214    int pBase = ndx * numRGB; 
     
    252257    initMinMax(); 
    253258 
     259    int numRGB = getRGBChannelCount(); 
     260 
    254261    // check whether min/max values have already been computed for this plane 
    255     if (planeMin[getSeries()][ndx] == planeMin[getSeries()][ndx]) return; 
     262    if (planeMin[getSeries()][ndx * numRGB] ==  
     263      planeMin[getSeries()][ndx * numRGB])  
     264    { 
     265      return; 
     266    } 
    256267 
    257268    boolean little = isLittleEndian(); 
     
    261272 
    262273    int[] coords = getZCTCoords(ndx); 
    263     int numRGB = getRGBChannelCount(); 
    264274    int cBase = coords[1] * numRGB; 
    265275    int pBase = ndx * numRGB; 
     
    269279    } 
    270280 
    271     byte[] value = new byte[bytes]; 
     281    boolean fp = getPixelType() == FormatTools.FLOAT ||  
     282      getPixelType() == FormatTools.DOUBLE; 
     283 
    272284    for (int i=0; i<pixels; i++) { 
    273285      for (int c=0; c<numRGB; c++) { 
    274286        int idx = bytes * (interleaved ? i * numRGB + c : c * pixels + i); 
    275         System.arraycopy(b, idx, value, 0, bytes); 
    276         long bits = DataTools.bytesToLong(value, little); 
    277         double v = Double.longBitsToDouble(bits); 
     287        long bits = DataTools.bytesToLong(b, idx, bytes, little); 
     288        double v = fp ? Double.longBitsToDouble(bits) : (double) bits;  
    278289        if (v > chanMax[getSeries()][cBase + c]) { 
    279290          chanMax[getSeries()][cBase + c] = v; 
     
    282293          chanMin[getSeries()][cBase + c] = v; 
    283294        } 
    284         if (v > planeMax[getSeries()][pBase + c]) { 
    285           planeMax[getSeries()][pBase + c] = v; 
     295        if (v > planeMax[getSeries()][ndx]) { 
     296          planeMax[getSeries()][ndx] = v; 
    286297        } 
    287298        if (v < planeMin[getSeries()][pBase + c]) { 
Note: See TracChangeset for help on using the changeset viewer.