Changeset 3253


Ignore:
Timestamp:
10/10/07 12:24:16 (12 years ago)
Author:
melissa
Message:

All byte array to float array conversions are now handled by DataTools.makeDataArray. Also fixed embarrassing bug in DataTools.normalizeFloats.

Location:
trunk/loci/formats
Files:
5 edited

Legend:

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

    r3204 r3253  
    119119 
    120120    if (getPixelType() == FormatTools.FLOAT) { 
    121       float[] f = new float[b.length / 4]; 
    122       for (int i=0; i<b.length; i+=4) { 
    123         f[i/4] = Float.intBitsToFloat(DataTools.bytesToInt(b, i, 4, 
    124           isLittleEndian())); 
    125       } 
     121      float[] f = 
     122        (float[]) DataTools.makeDataArray(b, 4, true, isLittleEndian()); 
    126123      if (isNormalized()) f = DataTools.normalizeFloats(f); 
    127124      return ImageTools.makeImage(f, getSizeX(), getSizeY()); 
  • trunk/loci/formats/DataTools.java

    r3097 r3253  
    516516 
    517517    for (int i=0; i<rtn.length; i++) { 
    518       rtn[i] = data[i] / max; 
    519       if (rtn[i] < 0f) rtn[i] = 0f; 
    520       if (rtn[i] > 1f) rtn[i] = 1f; 
     518      rtn[i] = (data[i] - min) / (max - min); 
    521519    } 
    522520 
  • trunk/loci/formats/FormatReader.java

    r3197 r3253  
    351351 
    352352    if (getPixelType() == FormatTools.FLOAT) { 
    353       float[] f = new float[buf.length / 4]; 
    354       for (int i=0; i<f.length; i++) { 
    355         int p = DataTools.bytesToInt(buf, i*4, 4, isLittleEndian()); 
    356         f[i] = Float.intBitsToFloat(p); 
    357       } 
     353      float[] f = 
     354        (float[]) DataTools.makeDataArray(buf, 4, true, isLittleEndian()); 
    358355 
    359356      if (normalizeData) f = DataTools.normalizeFloats(f); 
  • trunk/loci/formats/ImageTools.java

    r3204 r3253  
    251251      float[][] floats = new float[data.length][data[0].length / bps]; 
    252252      for (int i=0; i<floats.length; i++) { 
    253         for (int j=0; j<floats[0].length; j++) { 
    254           floats[i][j] = Float.intBitsToFloat( 
    255             DataTools.bytesToInt(data[i], j*4, 4, little)); 
    256         } 
     253        floats[i] = 
     254          (float[]) DataTools.makeDataArray(data[i], bps, true, little); 
    257255      } 
    258256      return makeImage(floats, w, h); 
  • trunk/loci/formats/TiffTools.java

    r3252 r3253  
    14051405        float[][] floatData = new float[samplesPerPixel][samples[0].length / 4]; 
    14061406        for (int i=0; i<samplesPerPixel; i++) { 
    1407           FloatBuffer sampleBuf = ByteBuffer.wrap(samples[i]).asFloatBuffer(); 
    1408           sampleBuf.get(floatData[i]); 
     1407          floatData[i] = (float[]) DataTools.makeDataArray(samples[i], 4, true, 
     1408            isLittleEndian(ifd)); 
    14091409        } 
    14101410        return ImageTools.makeImage(floatData, 
Note: See TracChangeset for help on using the changeset viewer.