Changeset 6513


Ignore:
Timestamp:
06/09/10 16:30:09 (10 years ago)
Author:
bdezonia
Message:

edits towards a general getColorTable() based testing method. Also enabled some code for debugging purposes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/test/loci/plugins/in/ImporterTest.java

    r6512 r6513  
    2323 
    2424import java.awt.Color; 
     25import java.awt.image.IndexColorModel; 
    2526import java.io.IOException; 
    2627import java.lang.reflect.Field; 
     
    361362    // else a regular ImagePlus 
    362363     
    363     if (channel != 0) 
    364       throw new IllegalArgumentException("getColorTable(): nonzero channel number requested of an ImagePlus."); 
    365      
    366     // TODO - figure out what to do here ... do I get a ColorModel from Imp somehow and build a LUT to use? 
    367      
    368     return null; 
     364    //if (channel != 0) 
     365    //  throw new IllegalArgumentException("getColorTable(): nonzero channel number requested of an ImagePlus."); 
     366     
     367    System.out.println("In here!!!!!"); 
     368     
     369    IndexColorModel icm = (IndexColorModel)imp.getStack().getColorModel(); 
     370     
     371    byte[] reds = new byte[256], greens = new byte[256], blues = new byte[256]; 
     372     
     373    icm.getReds(reds); 
     374    icm.getGreens(greens); 
     375    icm.getBlues(blues); 
     376     
     377    return new LUT(reds,greens,blues); 
    369378  } 
    370379   
    371380  /** get the actual pixel value (lookup when data is indexed) of the index of a fake image at a given z,c,t */ 
    372   private int getPixelValue(int x,int y,ImagePlus imp, int z, int c, int t, boolean indexed) 
     381  private int getPixelValue(int x,int y, ImagePlus imp, int z, int c, int t, boolean indexed) 
    373382  { 
    374383    // our indices are 0-based while IJ's are 1-based 
     
    392401  } 
    393402   
    394   private int getIndexPixelValue(CompositeImage ci, int z, int c, int t, boolean indexed) 
    395   { 
    396     return getPixelValue(10,0,ci,z,c,t,indexed); 
     403  private int getIndexPixelValue(ImagePlus imp, int z, int c, int t, boolean indexed) 
     404  { 
     405    return getPixelValue(10,0,imp,z,c,t,indexed); 
    397406  } 
    398407   
     
    21372146    
    21382147    int expectedSizeC = sizeC; 
    2139     //if (indexed && !falseColor) 
    2140     //  expectedSizeC = 3 * sizeC; 
    2141     //if ((totalPlanes == 1) && (expectedSizeC == 2) && falseColor) 
    2142     //  expectedSizeC = 3; 
    21432148     
    21442149    if (lutLen == -1) 
    21452150      lutLen = 3; 
    2146      
    2147     if ((indexed) && (!falseColor)) { 
    2148       expectedSizeC *= lutLen; 
    2149     } 
    2150     else if (indexed && falseColor) { 
    2151       expectedSizeC /= rgb; 
     2151 
     2152    if (indexed) 
     2153    { 
     2154      if (falseColor) 
     2155        expectedSizeC /= rgb; 
     2156      else // not falseColor 
     2157        expectedSizeC *= lutLen; 
    21522158    } 
    21532159       
     
    21692175      //colorTests(ci,expectedSizeC,DefaultColorOrder);  // TODO - was sizeC, also not passing (falseColor stuff needs to be impl???) 
    21702176       
    2171       if (indexed) 
    2172         System.out.println("  colorColorizedTester() - MaxZ MaxC MaxT "+sizeZ+" "+expectedSizeC+" "+sizeT); 
    2173  
    2174       int iIndex = 0; 
    2175       for (int cIndex = 0; cIndex < expectedSizeC; cIndex++) 
    2176         for (int tIndex = 0; tIndex < sizeT; tIndex++) 
    2177           for (int zIndex = 0; zIndex < sizeZ; zIndex++) 
    2178             getIndexPixelValue(ci, zIndex, cIndex, tIndex, indexed); 
    2179             //assertEquals(iIndex++,getIndexPixelValue(ci, zIndex, cIndex, tIndex, indexed)); 
    21802177    } 
    21812178    else 
    21822179      System.out.println("  Not a composite image"); 
     2180 
     2181    // TODO - this code was pulled out to allow mixing of CompImg and ImagePlus test code. Not working. 
     2182     
     2183    if (indexed) 
     2184      System.out.println("  colorColorizedTester() - MaxZ MaxC MaxT "+sizeZ+" "+expectedSizeC+" "+sizeT); 
     2185 
     2186    int iIndex = 0; 
     2187    for (int cIndex = 0; cIndex < expectedSizeC; cIndex++) 
     2188      for (int tIndex = 0; tIndex < sizeT; tIndex++) 
     2189        for (int zIndex = 0; zIndex < sizeZ; zIndex++) 
     2190          //getIndexPixelValue(imp, zIndex, cIndex, tIndex, indexed); 
     2191          assertEquals(iIndex++,getIndexPixelValue(imp, zIndex, cIndex, tIndex, indexed)); 
    21832192  } 
    21842193 
Note: See TracChangeset for help on using the changeset viewer.