@Override
  public RealSum call() throws Exception {
    final Cursor<FloatType> psiCursor = psiIterable.localizingCursor();
    psiCursor.jumpFwd(portion.getStartPosition());

    final int m = iterableImgs.size();

    if (compatibleIteration) {
      final ArrayList<Cursor<FloatType>> cursorWeights = new ArrayList<Cursor<FloatType>>();
      final ArrayList<Cursor<FloatType>> cursorImgs = new ArrayList<Cursor<FloatType>>();

      for (final IterableInterval<FloatType> img : iterableImgs) {
        final Cursor<FloatType> imgCursor = img.cursor();
        imgCursor.jumpFwd(portion.getStartPosition());
        cursorImgs.add(imgCursor);
      }

      for (final IterableInterval<FloatType> weight : iterableWeights) {
        final Cursor<FloatType> weightCursor = weight.cursor();
        weightCursor.jumpFwd(portion.getStartPosition());
        cursorWeights.add(weightCursor);
      }

      for (int j = 0; j < portion.getLoopSize(); ++j)
        compatibleLoop(psiCursor, cursorWeights, cursorImgs, realSum, m);
    } else {
      final ArrayList<RandomAccess<FloatType>> randomAccessWeights =
          new ArrayList<RandomAccess<FloatType>>();
      final ArrayList<RandomAccess<FloatType>> randomAccessImgs =
          new ArrayList<RandomAccess<FloatType>>();

      for (final RandomAccessibleInterval<FloatType> img : imgs)
        randomAccessImgs.add(img.randomAccess());

      for (final RandomAccessibleInterval<FloatType> weight : weights)
        randomAccessWeights.add(weight.randomAccess());

      for (int j = 0; j < portion.getLoopSize(); ++j)
        incompatibleLoop(psiCursor, randomAccessWeights, randomAccessImgs, realSum, m);
    }

    return realSum;
  }
示例#2
0
  @Test
  public void testIterableIntervalView() {
    @SuppressWarnings("unchecked")
    final IterableInterval<ByteType> res =
        (IterableInterval<ByteType>)
            ops.run(MapViewIterableIntervalToIterableInterval.class, in, op, new ByteType());

    final Cursor<ByteType> iterable = res.cursor();
    while (iterable.hasNext()) {
      assertEquals((byte) 10, iterable.next().get());
    }
  }
示例#3
0
 @Test
 public void testListDilateFull() {
   final List<Shape> shapes = new ArrayList<Shape>();
   shapes.add(new DiamondShape(1));
   shapes.add(new DiamondShape(1));
   shapes.add(new RectangleShape(1, false));
   shapes.add(new HorizontalLineShape(2, 1, false));
   @SuppressWarnings("unchecked")
   final IterableInterval<ByteType> out1 =
       (IterableInterval<ByteType>)
           ops.run(ListDilate.class, IterableInterval.class, in, shapes, true);
   final Img<ByteType> out2 = Dilation.dilateFull(in, shapes, 1);
   final Cursor<ByteType> c1 = out1.cursor();
   final Cursor<ByteType> c2 = out2.cursor();
   while (c1.hasNext()) assertEquals(c1.next().get(), c2.next().get());
 }
示例#4
0
  @Override
  public void map() {
    for (int d = 2; d < position.length; ++d) min[d] = max[d] = position[d];

    min[0] = target.min(0);
    min[1] = target.min(1);
    max[0] = target.max(0);
    max[1] = target.max(1);
    final FinalInterval sourceInterval = new FinalInterval(min, max);

    final Cursor<B> targetCursor = target.cursor();
    final RandomAccess<A> sourceRandomAccess = source.randomAccess(sourceInterval);
    sourceRandomAccess.setPosition(position);
    while (targetCursor.hasNext()) {
      final B b = targetCursor.next();
      sourceRandomAccess.setPosition(targetCursor.getLongPosition(0), 0);
      if (numDimensions > 1) sourceRandomAccess.setPosition(targetCursor.getLongPosition(1), 1);
      converter.convert(sourceRandomAccess.get(), b);
    }
  }