Java Code Examples for net.imglib2.RandomAccess#setPosition()

The following examples show how to use net.imglib2.RandomAccess#setPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractThresholdTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Before
public void initialize() {
	final long[] dimensions = new long[] { xSize, ySize };

	final Random r = new Random(0xdeadbeef);

	// create image and output
	in = ArrayImgs.unsignedShorts(dimensions);

	final RandomAccess<UnsignedShortType> ra = in.randomAccess();

	// populate pixel values with a ramp function + a constant
	for (int x = 0; x < xSize; x++) {
		for (int y = 0; y < ySize; y++) {
			ra.setPosition(new int[] { x, y });
			ra.get().setReal(r.nextInt(65535));
		}
	}
}
 
Example 2
Source File: MergeLabelingTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testMask() {
	final Img<BitType> mask = ops.create().img(in1, new BitType());
	final RandomAccess<BitType> maskRA = mask.randomAccess();
	maskRA.setPosition(new int[] { 0, 0 });
	maskRA.get().set(true);
	maskRA.setPosition(new int[] { 1, 1 });
	maskRA.get().set(true);
	@SuppressWarnings("unchecked")
	final MergeLabeling<Integer, ByteType, BitType> op = ops.op(
		MergeLabeling.class, out, in1, in2, mask);
	op.compute(in1, in2, out);
	final RandomAccess<LabelingType<Integer>> outRA = out.randomAccess();
	outRA.setPosition(new int[] { 0, 0 });
	assertTrue(outRA.get().contains(0));
	assertTrue(outRA.get().contains(10));
	outRA.setPosition(new int[] { 0, 1 });
	assertTrue(outRA.get().isEmpty());
}
 
Example 3
Source File: PermuteViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testIntervalPermuteCoordinates() {
	Img<DoubleType> img = ArrayImgs.doubles(2, 2);
	Cursor<DoubleType> c = img.cursor();
	MersenneTwisterFast r = new MersenneTwisterFast(SEED);
	while (c.hasNext()) {
		c.next().set(r.nextDouble());
	}
	IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[]{0, 1});
	Cursor<DoubleType> e = expected.cursor();
	RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[]{0, 1});
	RandomAccess<DoubleType> actualRA = actual.randomAccess();
	
	while (e.hasNext()) {
		e.next();
		actualRA.setPosition(e);
		assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
	}
	
	assertTrue(Intervals.equals(expected, actual));
	
}
 
Example 4
Source File: IntervalViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void defaultIntervalTest() {
	
	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
	
	MersenneTwisterFast r = new MersenneTwisterFast(SEED);
	for (DoubleType d : img) {
		d.set(r.nextDouble());
	}
	
	Cursor<DoubleType> il2 = Views.interval(img, img).localizingCursor();
	RandomAccess<DoubleType> opr = ops.transform().intervalView(img, img).randomAccess();

	
	while (il2.hasNext()) {
		DoubleType e = il2.next();
		opr.setPosition(il2);
		
		assertEquals(e.get(), opr.get().get(), 1e-10);
	}
}
 
Example 5
Source File: DistanceTransform3D.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Void call() throws Exception {
	final int[] s = new int[deep];
	final int[] t = new int[deep];
	int q = 0;
	s[0] = 0;
	t[0] = 0;

	// scan 3
	for (int u = 1; u < deep; u++) {
		while ((q >= 0) && (distancefunc(t[q], s[q], tempValues[xPos][yPos][s[q]]) > distancefunc(t[q], u,
				tempValues[xPos][yPos][u]))) {
			q--;
		}
		if (q < 0) {
			q = 0;
			s[0] = u;
		} else {
			final int w = 1 + sep(s[q], u, tempValues[xPos][yPos][u], tempValues[xPos][yPos][s[q]]);
			if (w < deep) {
				q++;
				s[q] = u;
				t[q] = w;
			}
		}
	}

	// scan 4
	final RandomAccess<T> ra = raOut.randomAccess();
	for (int u = deep - 1; u >= 0; u--) {
		ra.setPosition(xPos, 0);
		ra.setPosition(yPos, 1);
		ra.setPosition(u, 2);
		ra.get().setReal(Math.sqrt(distancefunc(u, s[q], tempValues[xPos][yPos][s[q]])));
		if (u == t[q]) {
			q--;
		}
	}
	return null;
}
 
Example 6
Source File: OutlineTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void assertPositionBackground(
	final RandomAccessibleInterval<BitType> interval, final long[] position)
{
	final RandomAccess<BitType> access = interval.randomAccess();
	access.setPosition(position);
	assertFalse("Element should be background", access.get().get());
}
 
Example 7
Source File: WatershedBinaryTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void assertResults(final ImgLabeling<Integer, IntType> expOut, final ImgLabeling<Integer, IntType> out) {
	Cursor<LabelingType<Integer>> expOutCursor = expOut.cursor();
	RandomAccess<LabelingType<Integer>> raOut = out.randomAccess();

	while (expOutCursor.hasNext()) {
		expOutCursor.fwd();
		raOut.setPosition(expOutCursor);
		assertEquals(expOutCursor.get().size(), raOut.get().size());
		if (expOutCursor.get().size() > 0)
			assertEquals(expOutCursor.get().iterator().next(), raOut.get().iterator().next());
	}

}
 
Example 8
Source File: Histogram2D.java    From Colocalisation_Analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A table of x-values, y-values and the counts is generated and
 * returned as a string. The single fields in one row (X Y Count)
 * are separated by tabs.
 *
 * @return A String representation of the histogram data.
 */
public String getData() {
	StringBuffer sb = new StringBuffer();

	double xBinWidth = 1.0 / getXBinWidth();
	double yBinWidth = 1.0 / getYBinWidth();
	double xMin = getXMin();
	double yMin = getYMin();
	// check if we have bins of size one or other ones
	boolean xBinWidthIsOne = Math.abs(xBinWidth - 1.0) < 0.00001;
	boolean yBinWidthIsOne = Math.abs(yBinWidth - 1.0) < 0.00001;
	// configure decimal places accordingly
	int xDecimalPlaces = xBinWidthIsOne ? 0 : 3;
	int yDecimalPlaces = yBinWidthIsOne ? 0 : 3;
	// create a cursor to access the histogram data
	RandomAccess<LongType> cursor = plotImage.randomAccess();
	// loop over 2D histogram
	for (int i=0; i < plotImage.dimension(0); ++i) {
		for (int j=0; j < plotImage.dimension(1); ++j) {
			cursor.setPosition(i, 0);
			cursor.setPosition(j, 1);
			sb.append(
					ResultsTable.d2s(xMin + (i * xBinWidth), xDecimalPlaces) + "\t" +
					ResultsTable.d2s(yMin + (j * yBinWidth), yDecimalPlaces) + "\t" +
					ResultsTable.d2s(cursor.get().getRealDouble(), 0) + "\n");
		}
	}

	return sb.toString();
}
 
Example 9
Source File: ConvertIIsTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testScale() {
	ops.run(ConvertIIs.class, out, in,
		new ScaleRealTypes<ShortType, ByteType>());

	final Cursor<ShortType> c = in.localizingCursor();
	final RandomAccess<ByteType> ra = out.randomAccess();
	while (c.hasNext()) {
		final short value = c.next().get();
		ra.setPosition(c);
		assertEquals(scale(value), ra.get().get());
	}
}
 
Example 10
Source File: Maps.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <I1, I2, O> void map(final RandomAccessibleInterval<I1> a,
	final RandomAccessibleInterval<I2> b, final IterableInterval<O> c,
	final BinaryComputerOp<I1, I2, O> op)
{
	final RandomAccess<I1> aAccess = a.randomAccess();
	final RandomAccess<I2> bAccess = b.randomAccess();
	final Cursor<O> cCursor = c.localizingCursor();
	while (cCursor.hasNext()) {
		cCursor.fwd();
		aAccess.setPosition(cCursor);
		bAccess.setPosition(cCursor);
		op.compute(aAccess.get(), bAccess.get(), cCursor.get());
	}
}
 
Example 11
Source File: ConvertIIsTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCopy() {
	ops.run(ConvertIIs.class, out, in,
		new CopyRealTypes<ShortType, ByteType>());

	final Cursor<ShortType> c = in.localizingCursor();
	final RandomAccess<ByteType> ra = out.randomAccess();
	while (c.hasNext()) {
		final short value = c.next().get();
		ra.setPosition(c);
		assertEquals(copy(value), ra.get().get());
	}
}
 
Example 12
Source File: WatershedSeededTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void test() {
	long[] dims = { 15, 30 };
	// create input image
	Img<FloatType> input = ArrayImgs.floats(dims);
	MersenneTwisterFast random = new MersenneTwisterFast(SEED);
	for (FloatType b : input) {
		b.setReal(random.nextDouble());
	}

	// create 3 seeds
	Img<BitType> bits = ArrayImgs.bits(dims);
	RandomAccess<BitType> ra = bits.randomAccess();
	ra.setPosition(new int[] { 0, 0 });
	ra.get().set(true);
	ra.setPosition(new int[] { 4, 6 });
	ra.get().set(true);
	ra.setPosition(new int[] { 10, 20 });
	ra.get().set(true);

	// compute labeled seeds
	final ImgLabeling<Integer, IntType> labeledSeeds = ops.labeling().cca(bits, StructuringElement.EIGHT_CONNECTED);

	testWithoutMask(input, labeledSeeds);

	testWithMask(input, labeledSeeds);
}
 
Example 13
Source File: EulerCharacteristic26N.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static <B extends BooleanType<B>> long getAtLocation(final RandomAccess<B> access, final long x,
                                                             final long y, final long z) {
    access.setPosition(x, 0);
    access.setPosition(y, 1);
    access.setPosition(z, 2);
    return (long) access.get().getRealDouble();
}
 
Example 14
Source File: Coloc_2.java    From Colocalisation_Analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method duplicates the given images, but respects ROIs if present.
 * Meaning, a sub-picture will be created when source images are
 * ROI/MaskImages.
 * 
 * @throws MissingPreconditionException
 */
protected RandomAccessibleInterval<T> createMaskImage(
	final RandomAccessibleInterval<T> image,
	final RandomAccessibleInterval<BitType> mask, final long[] offset,
	final long[] size) throws MissingPreconditionException
{
	final long[] pos = new long[image.numDimensions()];
	// sanity check
	if (pos.length != offset.length || pos.length != size.length) {
		throw new MissingPreconditionException(
			"Mask offset and size must be of same dimensionality like image.");
	}
	// use twin cursor for only one image
	final TwinCursor<T> cursor = new TwinCursor<>(image.randomAccess(), //
		image.randomAccess(), Views.iterable(mask).localizingCursor());
	// prepare output image
	final ImgFactory<T> maskFactory = new ArrayImgFactory<>();
	// Img<T> maskImage = maskFactory.create( size, name );
	final RandomAccessibleInterval<T> maskImage = maskFactory.create(size, //
		image.randomAccess().get().createVariable());
	final RandomAccess<T> maskCursor = maskImage.randomAccess();
	// go through the visible data and copy it to the output
	while (cursor.hasNext()) {
		cursor.fwd();
		cursor.localize(pos);
		// shift coordinates by offset
		for (int i = 0; i < pos.length; ++i) {
			pos[i] = pos[i] - offset[i];
		}
		// write out to correct position
		maskCursor.setPosition(pos);
		maskCursor.get().set(cursor.getFirst());
	}

	return maskImage;
}
 
Example 15
Source File: Block.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
private static final void paste( final long start, final long loopSize, final RandomAccessibleInterval< FloatType > target, final RandomAccessibleInterval< FloatType > block, 
		final long[] effectiveOffset, final long[] effectiveSize, final long[] effectiveLocalOffset )
{
	final int numDimensions = target.numDimensions();
	
	// iterate over effective size
	final LocalizingZeroMinIntervalIterator cursor = new LocalizingZeroMinIntervalIterator( effectiveSize );
	
	// read from block
	final RandomAccess<FloatType> blockRandomAccess  = block.randomAccess();
	
	// write to target		
	final RandomAccess<FloatType> targetRandomAccess  = target.randomAccess();
	
	cursor.jumpFwd( start );
	
	final long[] tmp = new long[ numDimensions ];
	
	for ( long l = 0; l < loopSize; ++l )
	{
		cursor.fwd();
		cursor.localize( tmp );
		
		// move to the relative local offset where the real data starts
		for ( int d = 0; d < numDimensions; ++d )
			tmp[ d ] += effectiveLocalOffset[ d ];
		
		blockRandomAccess.setPosition( tmp );
		
		// move to the right position in the image
		for ( int d = 0; d < numDimensions; ++d )
			tmp[ d ] += effectiveOffset[ d ] - effectiveLocalOffset[ d ];

		targetRandomAccess.setPosition( tmp );

		// write the pixel
		targetRandomAccess.get().set( blockRandomAccess.get() );
	}
}
 
Example 16
Source File: FloodFill2D.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Flood-fills the given mask starting at the specified 2D location in the viewer.
 * Returns the affected interval in source coordinates.
 *
 * @param x
 * @param y
 * @param viewer
 * @param mask
 * @param source
 * @param assignment
 * @param fillValue
 * @param fillDepth
 * @return affected interval
 */
public static <T extends IntegerType<T>> Interval fillMaskAt(
		final double x,
		final double y,
		final ViewerPanelFX viewer,
		final Mask<UnsignedLongType> mask,
		final MaskedSource<T, ?> source,
		final FragmentSegmentAssignment assignment,
		final long fillValue,
		final double fillDepth)
{
	final int time = mask.info.t;
	final int level = mask.info.level;

	final AffineTransform3D labelTransform = new AffineTransform3D();
	source.getSourceTransform(time, level, labelTransform);

	final RandomAccessibleInterval<T> background = source.getDataSource(time, level);
	final RandomAccess<T> access = background.randomAccess();
	final RealPoint pos = new RealPoint(access.numDimensions());
	viewer.displayToSourceCoordinates(x, y, labelTransform, pos);
	for (int d = 0; d < access.numDimensions(); ++d)
		access.setPosition(Math.round(pos.getDoublePosition(d)), d);
	final long seedLabel = assignment != null ? assignment.getSegment(access.get().getIntegerLong()) : access.get().getIntegerLong();
	LOG.debug("Got seed label {}", seedLabel);
	final RandomAccessibleInterval<BoolType> relevantBackground = Converters.convert(
			background,
			(src, tgt) -> tgt.set((assignment != null ? assignment.getSegment(src.getIntegerLong()) : src.getIntegerLong()) == seedLabel),
			new BoolType()
		);

	return fillMaskAt(x, y, viewer, mask, relevantBackground, labelTransform, fillValue, fillDepth);
}
 
Example 17
Source File: ShapeInterpolationMode.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private D getDataValue(final double x, final double y)
{
	final RealPoint sourcePos = getSourceCoordinates(x, y);
	final int time = activeViewer.getState().getTimepoint();
	final int level = MASK_SCALE_LEVEL;
	final RandomAccessibleInterval<D> data = source.getDataSource(time, level);
	final RandomAccess<D> dataAccess = data.randomAccess();
	for (int d = 0; d < sourcePos.numDimensions(); ++d)
		dataAccess.setPosition(Math.round(sourcePos.getDoublePosition(d)), d);
	return dataAccess.get();
}
 
Example 18
Source File: WatershedTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void testWithMask(final RandomAccessibleInterval<FloatType> in) {
	// create mask which is 1 everywhere
	long[] dims = new long[in.numDimensions()];
	in.dimensions(dims);
	Img<BitType> mask = ArrayImgs.bits(dims);
	RandomAccess<BitType> raMask = mask.randomAccess();
	for (BitType b : mask) {
		b.setZero();
	}
	for (int x = 0; x < dims[0] / 2; x++) {
		for (int y = 0; y < dims[1] / 2; y++) {
			raMask.setPosition(new int[] { x, y });
			raMask.get().setOne();
		}
	}

	/*
	 * use 8-connected neighborhood
	 */
	// compute result without watersheds
	ImgLabeling<Integer, IntType> out = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, true,
			false, mask);

	assertResults(in, out, mask, true, false, true);

	// compute result with watersheds
	ImgLabeling<Integer, IntType> out2 = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, true,
			true, mask);

	assertResults(in, out2, mask, true, true, true);

	/*
	 * use 4-connected neighborhood
	 */
	// compute result without watersheds
	ImgLabeling<Integer, IntType> out3 = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, false,
			false, mask);

	assertResults(in, out3, mask, false, false, true);

	// compute result with watersheds
	ImgLabeling<Integer, IntType> out4 = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, false,
			true, mask);

	assertResults(in, out4, mask, false, true, true);
}
 
Example 19
Source File: DefaultDetectRidges.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public List<? extends WritablePolyline> calculate(RandomAccessibleInterval<T> input) {

	double sigma = (width / (2 * Math.sqrt(3)));

	// generate the metadata images
	RidgeDetectionMetadata ridgeDetectionMetadata = new RidgeDetectionMetadata(input, sigma,
		lowerThreshold, higherThreshold);

	// retrieve the metadata images
	Img<DoubleType> p_values = ridgeDetectionMetadata.getPValues();
	Img<DoubleType> n_values = ridgeDetectionMetadata.getNValues();
	Img<DoubleType> gradients = ridgeDetectionMetadata.getGradients();

	// create RandomAccesses for the metadata images
	OutOfBoundsConstantValueFactory<DoubleType, RandomAccessibleInterval<DoubleType>> oscvf =
		new OutOfBoundsConstantValueFactory<>(new DoubleType(0));
	RandomAccess<DoubleType> pRA = oscvf.create(p_values);
	RandomAccess<DoubleType> nRA = oscvf.create(n_values);
	RandomAccess<DoubleType> gradientRA = oscvf.create(gradients);

	// create the output polyline list.
	List<DefaultWritablePolyline> lines = new ArrayList<>();

	// start at the point of greatest maximum absolute value
	gradientRA.setPosition(RidgeDetectionUtils.getMaxCoords(gradients, true));

	// loop through the maximum values of the image
	while (Math.abs(gradientRA.get().get()) > higherThreshold) {

		// create the List of points that will be used to make the polyline
		List<RealPoint> points = new ArrayList<>();

		// get all of the necessary metadata from the image.
		long[] eigenvectorPos = { gradientRA.getLongPosition(0), gradientRA
			.getLongPosition(1), 0 };

		// obtain the n-values
		nRA.setPosition(eigenvectorPos);
		double eigenx = nRA.get().getRealDouble();
		nRA.fwd(2);
		double eigeny = nRA.get().getRealDouble();

		// obtain the p-values
		pRA.setPosition(eigenvectorPos);
		double px = pRA.get().getRealDouble();
		pRA.fwd(2);
		double py = pRA.get().getRealDouble();

		// start the list by adding the current point, which is the most line-like
		// point on the polyline
		points.add(RidgeDetectionUtils.get2DRealPoint(gradientRA
			.getDoublePosition(0) + px, gradientRA.getDoublePosition(1) + py));

		// go in the direction to the left of the perpendicular value
		getNextPoint(gradientRA, pRA, nRA, points, RidgeDetectionUtils.getOctant(
			eigenx, eigeny), eigenx, eigeny, px, py);

		// flip the array list around so that we get one cohesive line
		gradientRA.setPosition(new long[] { eigenvectorPos[0],
			eigenvectorPos[1] });
		Collections.reverse(points);

		// go in the opposite direction as before.
		eigenx = -eigenx;
		eigeny = -eigeny;
		getNextPoint(gradientRA, pRA, nRA, points, RidgeDetectionUtils.getOctant(
			eigenx, eigeny), eigenx, eigeny, px, py);

		// set the value to 0 so that it is not reused.
		gradientRA.get().setReal(0);

		// turn the list of points into a polyline, add to output list. If the
		// list has fewer vertices than the parameter, then we do not report it.
		if (points.size() > ridgeLengthMin) {
			DefaultWritablePolyline pline = new DefaultWritablePolyline(points);
			lines.add(pline);
		}
		// find the next max absolute value
		gradientRA.setPosition(RidgeDetectionUtils.getMaxCoords(gradients, true));
	}

	return lines;
}
 
Example 20
Source File: Fusion.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper method to fuse all the positions of a given
 * {@link ClassifiedRegion}. Since we do not know the dimensionality of the
 * region, we recurse over each position of each dimension. The tail step of
 * each descent iterates over all the images (classes) of the given region,
 * fusing the pixel values at the current position of each associated image.
 * This final value is then set in the output.
 */
private void processTile(ClassifiedRegion r, int[] images, int depth,
	PixelFusion myFusion, ArrayList<InvertibleBoundable> transform,
	ArrayList<RealRandomAccess<? extends RealType<?>>> in,
	RandomAccess<T> out, double[][] inPos,
	int threadNumber, int[] count, long[] lastDraw, ImagePlus fusionImp)
	throws NoninvertibleModelException
{
	// NB: there are two process tile methods, one for in-memory fusion
	// and one for writing to disk. They are slightly different, but
	// if one is updated the other should be as well!
	if (depth < r.size()) {
		Interval d = r.get(depth);

		// The intervals of the given region define the bounds of
		// iteration
		// So we are recursively defining a nested iteration order to
		// cover each position of the region
		int start = d.min();
		int end = d.max();

		// If this is the dimension being split up for multi-threading we
		// need to update the iteration bounds.
		if (depth == loopDim[0]) {
			start += loopOffset;
			end = start + loopSize - 1;
		}

		out.setPosition(start, depth);

		// NB: can't make this loop inclusive since we don't want the out.fwd
		// call to go out of bounds, and we can't setPosition (-1) or we
		// get AIOOB exceptions. So we loop 1 time less than desired, then
		// do a straight read after the loop.
		for (int i = start; i < end; i++) {
			// Recurse to the next depth (dimension)
			processTile(r, images, depth + 1, myFusion, transform, in, out,
				inPos, threadNumber, count, lastDraw, fusionImp);
			// move forward
			out.fwd(depth);
		}

		// Need to read the final position.
		processTile(r, images, depth + 1, myFusion, transform, in, out,
			inPos, threadNumber, count, lastDraw, fusionImp);
		return;
	}

	// compute fusion for this position
	myFusion.clear();

	// Loop over the images in this region
	for (int d = 0; d < r.size(); d++) {
		final double value = out.getDoublePosition(d) + offset[d];

		for (int index = 0; index < images.length; index++) {
			// Get the positions for the current image
			inPos[images[index]][d] = value;
		}
	}

	// Get the value at each input position
	for (int index = 0; index < images.length; index++) {
		final int image = images[index];
		// Transform to get input position
		transform.get(image).applyInverseInPlace(inPos[image]);
		in.get(image).setPosition(inPos[image]);
		// fuse
		myFusion.addValue(in.get(image).get().getRealFloat(), image, inPos[image]);
	}

	// set value
	out.get().setReal(myFusion.getValue());

	// Display progress if on thread 0
	if (threadNumber == 0) {
		count[0]++;
		// just every 10000'th pixel
		if (count[0] % 10000 == 0) {
			lastDraw[0] = drawFusion(lastDraw[0], fusionImp);
			IJ.showProgress(count[0] / positionsPerThread);
		}
	}
}