Changeset 4692


Ignore:
Timestamp:
12/11/08 14:37:25 (11 years ago)
Author:
melissa
Message:

Only apply the rescaling function to signed data.

File:
1 edited

Legend:

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

    r4682 r4692  
    291291    } 
    292292 
    293     // apply rescale function 
    294  
    295     for (int i=0; i<w * h; i++) { 
    296       int pixel = DataTools.bytesToInt(buf, i * bpp, bpp, isLittleEndian()); 
    297       pixel = (int) (pixel * rescaleSlope + rescaleIntercept); 
    298       DataTools.unpackBytes(pixel, buf, i * bpp, bpp, isLittleEndian()); 
     293    // apply rescale function, if the data is signed 
     294    // we don't apply the rescale function to unsigned data because it can 
     295    // result in negative values (which cannot be properly handled if the 
     296    // data is unsigned) 
     297 
     298    if (getPixelType() == FormatTools.INT8 || 
     299      getPixelType() == FormatTools.INT16) 
     300    { 
     301      for (int i=0; i<w * h; i++) { 
     302        int pixel = DataTools.bytesToInt(buf, i * bpp, bpp, isLittleEndian()); 
     303        pixel = (int) (pixel * rescaleSlope + rescaleIntercept); 
     304        DataTools.unpackBytes(pixel, buf, i * bpp, bpp, isLittleEndian()); 
     305      } 
    299306    } 
    300307 
Note: See TracChangeset for help on using the changeset viewer.