Changeset 6541


Ignore:
Timestamp:
06/21/10 12:15:10 (9 years ago)
Author:
bdezonia
Message:

Improved falseColor support in getPixelValue().

File:
1 edited

Legend:

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

    r6537 r6541  
    200200 
    201201  /** Series number of the given ImagePlus at z,c,t index */ 
    202   private int sIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
    203   { 
    204     return getPixelValue(0,0,imp,z,c,t,indexed); 
     202  private int sIndex(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 
     203  { 
     204    return getPixelValue(0,0,imp,z,c,t,indexed,falseColor); 
    205205  } 
    206206   
    207207  /** Image number of the given ImagePlus at z,c,t index */ 
    208   private int iIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
    209   { 
    210     return getPixelValue(10,0,imp,z,c,t,indexed); 
     208  private int iIndex(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 
     209  { 
     210    return getPixelValue(10,0,imp,z,c,t,indexed,falseColor); 
    211211  } 
    212212   
    213213  /** Slice number of the given ImagePlus at z,c,t index */ 
    214   private int zIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
    215   { 
    216     return getPixelValue(20,0,imp,z,c,t,indexed); 
     214  private int zIndex(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 
     215  { 
     216    return getPixelValue(20,0,imp,z,c,t,indexed,falseColor); 
    217217  } 
    218218   
    219219  /** Channel number of the given ImagePlus at z,c,t index */ 
    220   private int cIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
    221   { 
    222     return getPixelValue(30,0,imp,z,c,t,indexed); 
     220  private int cIndex(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 
     221  { 
     222    return getPixelValue(30,0,imp,z,c,t,indexed,falseColor); 
    223223  } 
    224224   
    225225  /** Frame number of the given ImagePlus at z,c,t index */ 
    226   private int tIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
    227   { 
    228     return getPixelValue(40,0,imp,z,c,t,indexed); 
     226  private int tIndex(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 
     227  { 
     228    return getPixelValue(40,0,imp,z,c,t,indexed,falseColor); 
    229229  } 
    230230 
     
    444444   
    445445  /** get the actual pixel value (lookup when data is indexed) of the index of a fake image at a given z,c,t */ 
    446   private int getPixelValue(int x,int y, ImagePlus imp, int z, int c, int t, boolean indexed) 
     446  private int getPixelValue(int x,int y, ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 
    447447  { 
    448448    setZctPosition(imp,z,c,t); 
     
    450450    int rawValue = (int) (imp.getProcessor().getPixelValue(x, y)); 
    451451     
    452     if (!indexed) 
     452    if ((!indexed) || (falseColor)) 
    453453      return rawValue; 
    454454 
     
    562562   
    563563  /** helper test that verifies the indices of a FakeFile[z,c,t] match passed in values*/ 
    564   private void indexValuesTest(ImagePlus imp, int z, int c, int t, boolean indexed, int es, int ei, int ez, int ec, int et) 
    565   { 
    566     assertEquals(es,sIndex(imp, z, c, t, indexed)); 
    567     assertEquals(ei,iIndex(imp, z, c, t, indexed)); 
    568     assertEquals(ez,zIndex(imp, z, c, t, indexed)); 
    569     assertEquals(ec,cIndex(imp, z, c, t, indexed)); 
    570     assertEquals(et,tIndex(imp, z, c, t, indexed)); 
     564  private void indexValuesTest(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor, 
     565                                  int es, int ei, int ez, int ec, int et) 
     566  { 
     567    assertEquals(es,sIndex(imp, z, c, t, indexed,falseColor)); 
     568    assertEquals(ei,iIndex(imp, z, c, t, indexed,falseColor)); 
     569    assertEquals(ez,zIndex(imp, z, c, t, indexed,falseColor)); 
     570    assertEquals(ec,cIndex(imp, z, c, t, indexed,falseColor)); 
     571    assertEquals(et,tIndex(imp, z, c, t, indexed,falseColor)); 
    571572  } 
    572573   
    573574  /** tests that a FakeFile dataset has index values in ZCT order */ 
    574   private void stackInZctOrderTest(ImagePlus imp, int maxZ, int maxC, int maxT, boolean indexed) 
     575  private void stackInZctOrderTest(ImagePlus imp, int maxZ, int maxC, int maxT, boolean indexed, boolean falseColor) 
    575576  { 
    576577    stackTest(imp,(maxZ * maxC * maxT)); 
     
    589590          iIndex++; 
    590591           
    591           indexValuesTest(imp,z,c,t,indexed,expectedS,expectedI,expectedZ,expectedC,expectedT); 
     592          indexValuesTest(imp,z,c,t,indexed,falseColor,expectedS,expectedI,expectedZ,expectedC,expectedT); 
    592593        } 
    593594  } 
     
    654655   
    655656  /** tests that the pixel values of a FakeFile are as expected */ 
    656   private void pixelsTest(ImagePlus imp, int pixType, boolean indexed) 
     657  private void pixelsTest(ImagePlus imp, int pixType, boolean indexed, boolean falseColor) 
    657658  { 
    658659    assertTrue(pixType == FormatTools.UINT8);  // TODO - for now 
     
    666667        for (int z = 0; z < imp.getNSlices(); z++) 
    667668          for (int i = 0; i < max; i++) 
    668             assertEquals(i,getPixelValue(i,10,imp,z,c,t,indexed)); 
     669            assertEquals(i,getPixelValue(i,10,imp,z,c,t,indexed,falseColor)); 
    669670  } 
    670671 
     
    734735   
    735736  /** Tests that an ImageStack is ordered ZCT according to specified from/to/by points of z/c/t */ 
    736   private void seriesInZctOrderTest(ImagePlus imp, boolean indexed, 
     737  private void seriesInZctOrderTest(ImagePlus imp, boolean indexed, boolean falseColor, 
    737738      int zFrom, int zTo, int zBy, 
    738739      int cFrom, int cTo, int cBy, 
     
    749750        for (int z = 0; z < zs; z++) 
    750751        { 
    751           int zIndex = zIndex(imp,z,c,t,indexed); 
    752           int cIndex = cIndex(imp,z,c,t,indexed); 
    753           int tIndex = tIndex(imp,z,c,t,indexed); 
     752          int zIndex = zIndex(imp,z,c,t,indexed,falseColor); 
     753          int cIndex = cIndex(imp,z,c,t,indexed,falseColor); 
     754          int tIndex = tIndex(imp,z,c,t,indexed,falseColor); 
    754755           
    755756          int zVal = zFrom + z*zBy; 
     
    12591260          //indexValuesTest(ci, z, c, t, indexed, 0, index++, z, c, t); 
    12601261    */ 
    1261     stackInZctOrderTest(imp,sizeZ,expectedSizeC,sizeT,indexed); 
     1262    stackInZctOrderTest(imp,sizeZ,expectedSizeC,sizeT,indexed,falseColor); 
    12621263  } 
    12631264   
     
    15431544 
    15441545    // should be in correct order 
    1545     seriesInZctOrderTest(imp,false,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1546    seriesInZctOrderTest(imp,false,false,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    15461547  } 
    15471548   
     
    17781779    colorTests(ci,sizeC,DefaultColorOrder); 
    17791780       
    1780     stackInZctOrderTest(imp,sizeZ,sizeC,sizeT,indexed); 
    1781      
    1782     pixelsTest(imp,pixType,indexed); 
     1781    stackInZctOrderTest(imp,sizeZ,sizeC,sizeT,indexed,falseColor); 
     1782     
     1783    pixelsTest(imp,pixType,indexed,falseColor); 
    17831784  } 
    17841785   
     
    19191920  } 
    19201921 
     1922  // TODO - waiting to hear how this case should behave before implementation 
    19211923  @Test 
    19221924  public void testColorDefault() 
     
    19541956  } 
    19551957   
     1958  // TODO - older unfinished implementation : set aside for now and working on testCompositeSubcases()  
    19561959  @Test 
    19571960  public void testColorComposite() 
     
    19821985  } 
    19831986   
     1987  // TODO - older unfinished implementation : set aside for now and working on testColorizeSubcases()  
    19841988  @Test 
    19851989  public void testColorColorized() 
     
    19881992  } 
    19891993   
     1994  // TODO - older unfinished implementation. Waiting to adapt the newest colorize testing code when it is working 
    19901995  @Test 
    19911996  public void testColorGrayscale() 
     
    19941999  } 
    19952000   
     2001  // TODO - older unfinished implementation. Waiting to adapt the newest colorize testing code when it is working 
    19962002  @Test 
    19972003  public void testColorCustom() 
     
    25132519      for (int tIndex = 0; tIndex < sizeT; tIndex++) 
    25142520        for (int zIndex = 0; zIndex < sizeZ; zIndex++) 
    2515           getPixelValue(10,0,imp,zIndex,cIndex,tIndex,indexed); 
     2521          System.out.println("  iIndex pix val ("+zIndex+","+cIndex+","+tIndex+") = "+getPixelValue(10,0,imp,zIndex,cIndex,tIndex,indexed,falseColor)); 
    25162522          //assertEquals(iIndex++,getPixelValue(10,0,imp,zIndex,cIndex,tIndex,indexed)); 
    25172523 
Note: See TracChangeset for help on using the changeset viewer.