Changeset 6276
 Timestamp:
 05/11/10 15:28:10 (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/components/lociplugins/test/loci/plugins/in/ImporterTest.java
r6275 r6276 12 12 import ij.ImagePlus; 13 13 import ij.ImageStack; 14 import ij.process.FloatProcessor; 14 15 import ij.process.ImageProcessor; 15 16 … … 110 111 } 111 112 112 private int sIndex(ImageProcessor proc) { return proc.get(0,0); } // series 113 private int iIndex(ImageProcessor proc) { return proc.get(10,0); } // num in series 114 private int zIndex(ImageProcessor proc) { return proc.get(20,0); } // z 115 private int cIndex(ImageProcessor proc) { return proc.get(30,0); } // c 116 private int tIndex(ImageProcessor proc) { return proc.get(40,0); } // t 113 /** Series number of the given image processor. */ 114 private int sIndex(ImageProcessor proc) { return getPixel(proc, 0, 0); } 115 116 /** Image number of the given image processor. */ 117 private int iIndex(ImageProcessor proc) { return getPixel(proc, 10, 0); } 118 119 /** Slice number of the given image processor. */ 120 private int zIndex(ImageProcessor proc) { return getPixel(proc, 20, 0); } 121 122 /** Channel number of the given image processor. */ 123 private int cIndex(ImageProcessor proc) { return getPixel(proc, 30, 0); } 124 125 /** Frame number of the given image processor. */ 126 private int tIndex(ImageProcessor proc) { return getPixel(proc, 40, 0); } 127 128 private int getPixel(ImageProcessor proc, int x, int y) { 129 // NB: FloatProcessor returns the raw int bits when get(int, int) is 130 // called; to get actual value, we must call getf(int, int) and cast. 131 if (proc instanceof FloatProcessor) { 132 return (int) ((FloatProcessor) proc).getf(x, y); 133 } 134 return proc.get(x, y); 135 } 117 136 118 137 @SuppressWarnings("unused") … … 352 371 int actualZ = getSizeZ(imp); 353 372 int actualT = getSizeT(imp); 354 assertEquals(z,actualT); 355 assertEquals(t,actualZ); 373 assertEquals(z,actualT); // Z<>T swapped 374 assertEquals(t,actualZ); // Z<>T swapped 356 375 357 376 // make sure the dimensions were swapped correctly 358 // notice I'm testing from inside out in ZCT order but using input z for T and the input t for Z 377 // notice I'm testing from inside out in ZCT order 378 // but using input z for T and the input t for Z 359 379 int p = 1; 360 for (int k = 0; k < z; k++)361 for (int j = 0; j < c; j++)362 for (int i = 0; i < t; i++)380 for (int zIndex = 0; zIndex < z; zIndex++) 381 for (int cIndex = 0; cIndex < c; cIndex++) 382 for (int tIndex = 0; tIndex < t; tIndex++) 363 383 { 364 ImageProcessor proc = st.getProcessor(p); 365 assertEquals(i,zIndex(proc)); 366 assertEquals(j,cIndex(proc)); 367 assertEquals(k,tIndex(proc)); 368 p++; 384 ImageProcessor proc = st.getProcessor(p++); 385 assertEquals(tIndex,zIndex(proc)); // Z<>T swapped 386 assertEquals(cIndex,cIndex(proc)); 387 assertEquals(zIndex,tIndex(proc)); // Z<>T swapped 369 388 } 370 389 }
Note: See TracChangeset
for help on using the changeset viewer.