Example #1
0
  @Before
  public void createSourceData() {
    dimensions = new long[] {48, 17, 102};

    numValues = 1;
    for (int d = 0; d < dimensions.length; ++d) numValues *= dimensions[d];

    intData = new int[numValues];
    intDataSum = 0;
    final Random random = new Random(0);
    for (int i = 0; i < numValues; ++i) {
      intData[i] = random.nextInt();
      intDataSum += intData[i];
    }

    intImg = new ListImgFactory<IntType>().create(dimensions, new IntType());

    final long[] pos = new long[dimensions.length];
    final RandomAccess<IntType> a = intImg.randomAccess();

    for (int i = 0; i < numValues; ++i) {
      IntervalIndexer.indexToPosition(i, dimensions, pos);
      a.setPosition(pos);
      a.get().set(intData[i]);
    }
  }
Example #2
0
 int[] getImgAsInts(final Img<IntType> img) {
   final RandomAccess<IntType> a = img.randomAccess();
   final int N = (int) img.size();
   final int[] data = new int[N];
   final long[] dim = new long[img.numDimensions()];
   final long[] pos = new long[img.numDimensions()];
   img.dimensions(dim);
   for (int i = 0; i < N; ++i) {
     IntervalIndexer.indexToPosition(i, dim, pos);
     a.setPosition(pos);
     data[i] = a.get().get();
   }
   return data;
 }
Example #3
0
 public void indexToGlobalPosition(final int index, final long[] position) {
   IntervalIndexer.indexToPosition(index, dimensions, position);
   for (int d = 0; d < position.length; ++d) position[d] += min[d];
 }
Example #4
0
 public long indexToGlobalPosition(final int index, final int d) {
   return IntervalIndexer.indexToPosition(index, dimensions, steps, d) + min[d];
 }
Example #5
0
 @Override
 public void localize(final int[] position) {
   IntervalIndexer.indexToPosition(type.getIndex(), container.dim, position);
 }
Example #6
0
 @Override
 public int getIntPosition(final int dim) {
   return IntervalIndexer.indexToPosition(type.getIndex(), container.dim, dim);
 }
 @Override
 public void jumpFwd(final long i) {
   index += i;
   IntervalIndexer.indexToPosition(index, dimensions, position);
 }