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

The following examples show how to use net.imglib2.view.Views#hyperSlice() . 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: FrangiVesselness.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void run() {
	// parse the spacing, and scales strings.
	spacing = checkDimensions(spacingString, input.numDimensions(), "Spacings");
	scales = Arrays.stream(scaleString.split(regex)).mapToInt(Integer::parseInt)
		.toArray();
	Dimensions resultDims = Views.addDimension(input, 0, scales.length - 1);
	// create output image, potentially-filtered input
	result = opService.create().img(resultDims, new FloatType());

	for (int s = 0; s < scales.length; s++) {
		// Determine whether or not the user would like to apply the gaussian
		// beforehand and do it.
		RandomAccessibleInterval<T> vesselnessInput = doGauss ? opService.filter()
			.gauss(input, scales[s]) : input;
		IntervalView<FloatType> scaleResult = Views.hyperSlice(result, result
			.numDimensions() - 1, s);
		opService.filter().frangiVesselness(scaleResult, vesselnessInput, spacing,
			scales[s]);
	}
}
 
Example 2
Source File: HyperSliceViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void defaultHyperSliceTest() {

	final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 },
			new DoubleType());

	final MixedTransformView<DoubleType> il2 = Views.hyperSlice((RandomAccessible<DoubleType>) img, 1, 8);
	final MixedTransformView<DoubleType> opr = ops.transform().hyperSliceView(deinterval(img), 1, 8);

	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 3
Source File: HyperSliceViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void IntervalHyperSliceTest() {

	final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 },
			new DoubleType());

	final IntervalView<DoubleType> il2 = Views.hyperSlice((RandomAccessibleInterval<DoubleType>) img, 1, 8);
	final IntervalView<DoubleType> opr = ops.transform().hyperSliceView(img, 1, 8);

	for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
			.getMatrix().length; i++) {
		for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
				.getMatrix()[i].length; j++) {
			assertEquals(
					((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j],
					((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j],
					1e-10);
		}
	}

	assertEquals(img.numDimensions() - 1, opr.numDimensions());
}
 
Example 4
Source File: ShapeInterpolationMode.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private RandomAccessibleInterval<UnsignedLongType> getTransformedMaskSection(final SectionInfo sectionInfo)
{
	final RealInterval sectionBounds = sectionInfo.sourceToDisplayTransform.estimateBounds(sectionInfo.sourceBoundingBox);
	final Interval sectionInterval = Intervals.smallestContainingInterval(sectionBounds);
	final RealRandomAccessible<UnsignedLongType> transformedMask = getTransformedMask(sectionInfo.mask, sectionInfo.sourceToDisplayTransform);
	final RandomAccessibleInterval<UnsignedLongType> transformedMaskInterval = Views.interval(Views.raster(transformedMask), sectionInterval);
	return Views.hyperSlice(transformedMaskInterval, 2, 0l);
}
 
Example 5
Source File: IntervalHyperSliceView.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.hyperSlice(input, d, pos);
}
 
Example 6
Source File: DefaultHyperSliceView.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.hyperSlice(input, d, pos);
}