Changeset 2256


Ignore:
Timestamp:
02/12/07 12:54:20 (13 years ago)
Author:
callan
Message:
  • Absolves the responsibility of handling min/max calculation from the Readers
  • Fixes Deltavision reader bug that indexes channels from 0 rather than 1
Location:
trunk/loci/formats/in
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/BaseTiffReader.java

    r2219 r2256  
    4646  /** The maximum index in the channelMinMax array */ 
    4747  private static final int MAX = 1; 
    48  
     48         
    4949  // -- Fields -- 
    5050 
     
    560560      // populate Logical Channel elements 
    561561      for (int i=0; i<getSizeC(currentId); i++) { 
    562         try { 
    563           setLogicalChannel(i); 
    564           if ((getChannelGlobalMinimum(currentId, 0) == null || 
    565             getChannelGlobalMaximum(currentId, 0) == null) && 
    566             enableChannelStatCalculation) 
    567           { 
    568             setChannelGlobalMinMax(i); 
    569           } 
    570         } 
    571         catch (FormatException e) { 
    572           if (debug) e.printStackTrace(); 
    573         } 
    574         catch (IOException e) { 
    575           if (debug) e.printStackTrace(); 
    576         } 
     562        setLogicalChannel(i); 
     563        setChannelGlobalMinMax(i); 
    577564      } 
    578565 
     
    847834    throws FormatException, IOException 
    848835  { 
    849     getChannelGlobalMinMax(); 
    850     getMetadataStore(currentId).setChannelGlobalMinMax(channelIdx, 
    851         channelMinMax[channelIdx][MIN], channelMinMax[channelIdx][MAX], null); 
    852   } 
    853  
    854   /** 
    855    * Retrieves the global min and max for each channel. 
    856    * @throws FormatException if there is an error parsing metadata. 
    857    * @throws IOException if there is an error reading the file. 
    858    */ 
    859   public void getChannelGlobalMinMax() throws FormatException, IOException { 
    860     if (channelMinMax == null) { 
    861       channelMinMax = new Double[getSizeC(currentId)][2]; 
    862     } 
    863     else return; 
    864  
    865     for (int c = 0; c < getSizeC(currentId); c++) { 
    866       double min = Double.MAX_VALUE; 
    867       double max = Double.MIN_VALUE; 
    868       for (int t = 0; t < getSizeT(currentId); t++) { 
    869         for (int z = 0; z < getSizeZ(currentId); z++) { 
    870           int index = getIndex(currentId, z, c, t); 
    871           WritableRaster pixels = openImage(currentId, index).getRaster(); 
    872           for (int x = 0; x < getSizeX(currentId); x++) { 
    873             for (int y = 0; y < getSizeY(currentId); y++) { 
    874               double pixelValue = pixels.getSampleDouble(x, y, c); 
    875               if (pixelValue < min) min = pixelValue; 
    876               if (pixelValue > max) max = pixelValue; 
    877             } 
    878           } 
    879         } 
    880       } 
    881       channelMinMax[c][MIN] = new Double(min); 
    882       channelMinMax[c][MAX] = new Double(max); 
    883     } 
     836    Double min = getChannelGlobalMinimum(currentId, channelIdx); 
     837    Double max = getChannelGlobalMaximum(currentId, channelIdx); 
     838    getMetadataStore(currentId).setChannelGlobalMinMax(channelIdx, min, 
     839                                                       max, null); 
    884840  } 
    885841 
  • trunk/loci/formats/in/DeltavisionReader.java

    r2182 r2256  
    155155  { 
    156156    if (!id.equals(currentId)) initFile(id); 
    157     Float v = (Float) getMeta("Wavelength " + theC + " min. intensity"); 
     157    Float v = (Float) getMeta("Wavelength " + (theC + 1) + " min. intensity"); 
    158158    return new Double(v.floatValue()); 
    159159  } 
     
    164164  { 
    165165    if (!id.equals(currentId)) initFile(id); 
    166     Float v = (Float) getMeta("Wavelength " + theC + " max. intensity"); 
     166    Float v = (Float) getMeta("Wavelength " + (theC + 1) + " max. intensity"); 
    167167    return new Double(v.floatValue()); 
    168168  } 
Note: See TracChangeset for help on using the changeset viewer.