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

The following examples show how to use net.imglib2.view.Views#collapse() . 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: LocalThresholdIntegral.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void compute(final RandomAccessibleInterval<I> input,
	final IterableInterval<BitType> output)
{

	final List<RandomAccessibleInterval<RealType>> listOfIntegralImages =
		new ArrayList<>();
	for (final int order : requiredIntegralImages()) {
		final RandomAccessibleInterval<RealType> requiredIntegralImg =
			getIntegralImage(input, order);
		listOfIntegralImages.add(requiredIntegralImg);
	}

	// Composite image of integral images of order 1 and 2
	final RandomAccessibleInterval<RealType> stacked = Views.stack(
		listOfIntegralImages);
	final RandomAccessibleInterval<? extends Composite<RealType>> compositeRAI =
		Views.collapse(stacked);
	final RandomAccessibleInterval<? extends Composite<RealType>> extendedCompositeRAI =
		removeLeadingZeros(compositeRAI);

	final NeighborhoodsIterableInterval<? extends Composite<RealType>> neighborhoods =
		shape.neighborhoodsSafe(extendedCompositeRAI);

	if (map == null) {
		map = (BinaryComputerOp) ops().op(Map.class, out(), in(), neighborhoods,
			filterOp);
	}

	map.compute(input, neighborhoods, output);
}
 
Example 2
Source File: CollapseViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void defaultCollapseTest() {
	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 },
			new DoubleType());

	CompositeIntervalView<DoubleType, ? extends GenericComposite<DoubleType>> il2 = Views
			.collapse(img);
	CompositeIntervalView<DoubleType, ? extends GenericComposite<DoubleType>> opr = ops.transform()
			.collapseView(img);

	assertEquals(il2.numDimensions(), opr.numDimensions());
}
 
Example 3
Source File: DefaultCollapse2CompositeIntervalView.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public CompositeIntervalView<T, ? extends GenericComposite<T>> calculate(RandomAccessibleInterval<T> input) {
	return Views.collapse(input);
}
 
Example 4
Source File: DefaultCollapse2CompositeView.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public CompositeView<T, ? extends GenericComposite<T>> calculate(RandomAccessible<T> input) {
	return Views.collapse(input);
}
 
Example 5
Source File: CollapseViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 3 votes vote down vote up
@Test
public void collapseRATest() {

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

	CompositeView<DoubleType, ? extends GenericComposite<DoubleType>> il2 = Views
			.collapse((RandomAccessible<DoubleType>) img);

	CompositeView<DoubleType, ? extends GenericComposite<DoubleType>> opr = ops.transform()
			.collapseView((RandomAccessible<DoubleType>) img);

	assertEquals(il2.numDimensions(), opr.numDimensions());
}
 
Example 6
Source File: CollapseViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 3 votes vote down vote up
@Test
public void collapseRAITest() {

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

	CompositeIntervalView<DoubleType, ? extends GenericComposite<DoubleType>> il2 = Views
			.collapse((RandomAccessibleInterval<DoubleType>) img);

	CompositeIntervalView<DoubleType, ? extends GenericComposite<DoubleType>> opr = ops.transform()
			.collapseView((RandomAccessibleInterval<DoubleType>) img);

	assertEquals(il2.numDimensions(), opr.numDimensions());
}