Changeset 4029


Ignore:
Timestamp:
05/09/08 11:37:40 (12 years ago)
Author:
melissa
Message:

Fixed bug in how double images are handled.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

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

    r3969 r4029  
    675675  } 
    676676 
     677  /** 
     678   * Normalize the given double array so that the minimum value maps to 0.0 
     679   * and the maximum value maps to 1.0. 
     680   */ 
     681  public static double[] normalizeDoubles(double[] data) { 
     682    double[] rtn = new double[data.length]; 
     683 
     684    double min = Double.MAX_VALUE; 
     685    double max = Double.MIN_VALUE; 
     686 
     687    for (int i=0; i<data.length; i++) { 
     688      if (data[i] < min) min = data[i]; 
     689      if (data[i] > max) max = data[i]; 
     690    } 
     691 
     692    for (int i=0; i<rtn.length; i++) { 
     693      rtn[i] = (data[i] - min) / (max - min); 
     694    } 
     695    return rtn; 
     696  } 
     697 
    677698  // -- Date handling -- 
    678699 
  • trunk/loci/formats/ImageTools.java

    r4001 r4029  
    482482      if (r.isNormalized()) f = DataTools.normalizeFloats(f); 
    483483      return makeImage(f, w, h, r.getRGBChannelCount(), true); 
     484    } 
     485    else if (pixelType == FormatTools.DOUBLE) { 
     486      double[] d = 
     487        (double[]) DataTools.makeDataArray(buf, 8, true, r.isLittleEndian()); 
     488      if (r.isNormalized()) d = DataTools.normalizeDoubles(d); 
     489      return makeImage(d, w, h, r.getRGBChannelCount(), true); 
    484490    } 
    485491 
Note: See TracChangeset for help on using the changeset viewer.