Changeset 2442
 Timestamp:
 03/14/07 11:24:18 (13 years ago)
 Location:
 trunk/loci/formats
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/loci/formats/FileStitcher.java
r2430 r2442 916 916 // get Z, C and T positions 917 917 int[] zct = getZCTCoords(id, no); 918 int[] posZ = rasterToPosition(lenZ[sno], zct[0]);919 int[] posC = rasterToPosition(lenC[sno], zct[1]);920 int[] posT = rasterToPosition(lenT[sno], zct[2]);918 int[] posZ = FormatTools.rasterToPosition(lenZ[sno], zct[0]); 919 int[] posC = FormatTools.rasterToPosition(lenC[sno], zct[1]); 920 int[] posT = FormatTools.rasterToPosition(lenT[sno], zct[2]); 921 921 922 922 // convert Z, C and T position lists into file index and image index … … 932 932 } 933 933 } 934 int fno = positionToRaster(count, pos);934 int fno = FormatTools.positionToRaster(count, pos); 935 935 int ino = FormatTools.getIndex(order[sno], sizeZ[sno], 936 936 reader.getEffectiveSizeC(files[0]), sizeT[sno], imagesPerFile[sno], … … 965 965 } 966 966 967 //  Utility methods 968 969 /**970 * Computes a unique 1D index corresponding to the multidimensional971 * position given in the pos array, using the specified lengths array972 * as the maximum value at each positional dimension.973 */974 public static int positionToRaster(int[] lengths, int[] pos) {975 int[] offsets = new int[lengths.length];976 if (offsets.length > 0) offsets[0] = 1;977 for (int i=1; i<offsets.length; i++) {978 offsets[i] = offsets[i  1] * lengths[i  1];979 }980 int raster = 0;981 for (int i=0; i<pos.length; i++) raster += offsets[i] * pos[i];982 return raster;983 }984 985 /**986 * Computes a unique 3D position corresponding to the given raster987 * value, using the specified lengths array as the maximum value at988 * each positional dimension.989 */990 public static int[] rasterToPosition(int[] lengths, int raster) {991 int[] offsets = new int[lengths.length];992 if (offsets.length > 0) offsets[0] = 1;993 for (int i=1; i<offsets.length; i++) {994 offsets[i] = offsets[i  1] * lengths[i  1];995 }996 int[] pos = new int[lengths.length];997 for (int i=0; i<pos.length; i++) {998 int q = i < pos.length  1 ? raster % offsets[i + 1] : raster;999 pos[i] = q / offsets[i];1000 raster = q;1001 }1002 return pos;1003 }1004 1005 /**1006 * Computes the maximum raster value of a positional array with1007 * the given maximum values.1008 */1009 public static int getRasterLength(int[] lengths) {1010 int len = 1;1011 for (int i=0; i<lengths.length; i++) len *= lengths[i];1012 return len;1013 }1014 1015 967 //  Main method  1016 968 
trunk/loci/formats/FormatTools.java
r2430 r2442 446 446 } 447 447 448 //  Dimensional positions  449 448 450 /** 449 451 * Gets the rasterized index corresponding … … 592 594 return new int[] {z, c, t}; 593 595 } 596 597 /** 598 * Computes a unique 1D index corresponding to the multidimensional 599 * position given in the pos array, using the specified lengths array 600 * as the maximum value at each positional dimension. 601 */ 602 public static int positionToRaster(int[] lengths, int[] pos) { 603 int[] offsets = new int[lengths.length]; 604 if (offsets.length > 0) offsets[0] = 1; 605 for (int i=1; i<offsets.length; i++) { 606 offsets[i] = offsets[i  1] * lengths[i  1]; 607 } 608 int raster = 0; 609 for (int i=0; i<pos.length; i++) raster += offsets[i] * pos[i]; 610 return raster; 611 } 612 613 /** 614 * Computes a unique 3D position corresponding to the given raster 615 * value, using the specified lengths array as the maximum value at 616 * each positional dimension. 617 */ 618 public static int[] rasterToPosition(int[] lengths, int raster) { 619 int[] offsets = new int[lengths.length]; 620 if (offsets.length > 0) offsets[0] = 1; 621 for (int i=1; i<offsets.length; i++) { 622 offsets[i] = offsets[i  1] * lengths[i  1]; 623 } 624 int[] pos = new int[lengths.length]; 625 for (int i=0; i<pos.length; i++) { 626 int q = i < pos.length  1 ? raster % offsets[i + 1] : raster; 627 pos[i] = q / offsets[i]; 628 raster = q; 629 } 630 return pos; 631 } 632 633 /** 634 * Computes the maximum raster value of a positional array with 635 * the given maximum values. 636 */ 637 public static int getRasterLength(int[] lengths) { 638 int len = 1; 639 for (int i=0; i<lengths.length; i++) len *= lengths[i]; 640 return len; 641 } 642 643 //  Pixel types  594 644 595 645 /**
Note: See TracChangeset
for help on using the changeset viewer.