Changeset 6408


Ignore:
Timestamp:
05/27/10 11:59:11 (10 years ago)
Author:
curtis
Message:

Fix image calibration bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/src/loci/plugins/util/ImagePlusTools.java

    r6311 r6408  
    137137    if (td != null) tcal = td.floatValue(); 
    138138 
    139     boolean xcalMissing = Double.isNaN(xcal); 
    140     boolean ycalMissing = Double.isNaN(ycal); 
    141     boolean zcalMissing = Double.isNaN(zcal); 
    142     boolean tcalMissing = Double.isNaN(tcal); 
    143     if (xcalMissing || ycalMissing || zcalMissing || tcalMissing) { 
    144       // if the physical width or physical height are missing, assume that 
    145       // the width and height are equal 
    146       if (!xcalMissing) xcal = ycal; 
    147       if (!ycalMissing) ycal = xcal; 
    148  
     139    final boolean xcalPresent = !Double.isNaN(xcal); 
     140    final boolean ycalPresent = !Double.isNaN(ycal); 
     141    final boolean zcalPresent = !Double.isNaN(zcal); 
     142    final boolean tcalPresent = !Double.isNaN(tcal); 
     143 
     144    // if the physical width or physical height are missing, 
     145    // assume that the width and height are equal 
     146    if (xcalPresent && !ycalPresent) ycal = xcal; 
     147    else if (ycalPresent && !xcalPresent) xcal = ycal; 
     148 
     149    final boolean hasSpatial = xcalPresent || ycalPresent || zcalPresent; 
     150    final boolean hasCalibration = hasSpatial || ycalPresent; 
     151 
     152    if (hasCalibration) { 
     153      // set calibration only if at least one value is present 
    149154      Calibration cal = new Calibration(); 
    150       cal.setUnit("micron"); 
    151       cal.pixelWidth = xcal; 
    152       cal.pixelHeight = ycal; 
    153       cal.pixelDepth = zcal; 
    154       cal.frameInterval = tcal; 
     155      if (hasSpatial) cal.setUnit("micron"); 
     156      if (xcalPresent) cal.pixelWidth = xcal; 
     157      if (ycalPresent) cal.pixelHeight = ycal; 
     158      if (zcalPresent) cal.pixelDepth = zcal; 
     159      if (tcalPresent) cal.frameInterval = tcal; 
    155160      imp.setCalibration(cal); 
    156161    } 
Note: See TracChangeset for help on using the changeset viewer.