Java Code Examples for net.imglib2.view.Views#translate()

The following examples show how to use net.imglib2.view.Views#translate() . 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: DefaultErode.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final RandomAccessibleInterval<T> in1, final Shape in2,
	final IterableInterval<T> output)
{
	final RandomAccessibleInterval<T> shifted;
	if (isFull) {
		final long[] offset = MorphologyUtils
			.computeTargetImageDimensionsAndOffset(in1, in2)[1];
		shifted = Views.translate(in1, offset);
	}
	else {
		shifted = in1;
	}
	final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extended =
		Views.extend(shifted, f);
	Erosion.erode(extended, output, in2, maxVal, Runtime.getRuntime()
		.availableProcessors());
}
 
Example 2
Source File: DefaultDilate.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final RandomAccessibleInterval<T> in1, final Shape in2,
	final IterableInterval<T> output)
{
	final RandomAccessibleInterval<T> shifted;
	if (isFull) {
		final long[] offset = MorphologyUtils
			.computeTargetImageDimensionsAndOffset(in1, in2)[1];
		shifted = Views.translate(in1, offset);
	}
	else {
		shifted = in1;
	}
	final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extended =
		Views.extend(shifted, f);
	Dilation.dilate(extended, output, in2, minVal, Runtime.getRuntime()
		.availableProcessors());
}
 
Example 3
Source File: TranslateViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testIntervalTranslate() {
	Img<DoubleType> img = ArrayImgs.doubles(10,10);

	IntervalView<DoubleType> expected = Views.translate(img, 2, 5);
	IntervalView<DoubleType> actual = ops.transform().translateView(img, 2, 5);

	for (int i = 0; i < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix().length; i++) {
		for (int j = 0; j < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
			assertEquals(((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) actual.getSource()).getTransformToSource().getMatrix()[i][j],
					1e-10);
		}
	}
	
	assertTrue(Intervals.equals(expected, actual));
}
 
Example 4
Source File: TranslateViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void defaultTranslateTest() {
	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());

	MixedTransformView<DoubleType> il2 = Views.translate( deinterval(img), 2, 5);
	MixedTransformView<DoubleType> opr = ops.transform().translateView( deinterval(img), 2, 5);


	for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
		for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
			assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j],
					1e-10);
		}
	}
}
 
Example 5
Source File: IntervalTranslateView.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public IntervalView<T> calculate(final RandomAccessibleInterval<T> input) {
	return Views.translate(input, translation);
}
 
Example 6
Source File: DefaultTranslateView.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public MixedTransformView<T> calculate(RandomAccessible<T> input) {
	return Views.translate(input, translation);
}