示例#1
0
 public Properties decodeDescriptionString(FileInfo fi) {
   if (fi.description == null || fi.description.length() < 7) return null;
   if (IJ.debugMode) IJ.log("Image Description: " + new String(fi.description).replace('\n', ' '));
   if (!fi.description.startsWith("ImageJ")) return null;
   Properties props = new Properties();
   InputStream is = new ByteArrayInputStream(fi.description.getBytes());
   try {
     props.load(is);
     is.close();
   } catch (IOException e) {
     return null;
   }
   fi.unit = props.getProperty("unit", "");
   Double n = getNumber(props, "cf");
   if (n != null) fi.calibrationFunction = n.intValue();
   double c[] = new double[5];
   int count = 0;
   for (int i = 0; i < 5; i++) {
     n = getNumber(props, "c" + i);
     if (n == null) break;
     c[i] = n.doubleValue();
     count++;
   }
   if (count >= 2) {
     fi.coefficients = new double[count];
     for (int i = 0; i < count; i++) fi.coefficients[i] = c[i];
   }
   fi.valueUnit = props.getProperty("vunit");
   n = getNumber(props, "images");
   if (n != null && n.doubleValue() > 1.0) fi.nImages = (int) n.doubleValue();
   if (fi.nImages > 1) {
     double spacing = getDouble(props, "spacing");
     if (spacing != 0.0) {
       if (spacing < 0) spacing = -spacing;
       fi.pixelDepth = spacing;
     }
   }
   return props;
 }