Java Code Examples for net.imglib2.type.numeric.integer.ByteType#set()

The following examples show how to use net.imglib2.type.numeric.integer.ByteType#set() . 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: MapTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testIIAndIIInplace() {
	final Img<ByteType> first = generateByteArrayTestImg(true, 10, 10);
	final Img<ByteType> firstCopy = first.copy();
	final Img<ByteType> second = generateByteArrayTestImg(false, 10, 10);
	for (final ByteType px : second)
		px.set((byte) 1);
	final Img<ByteType> secondCopy = second.copy();
	final Img<ByteType> secondDiffDims = generateByteArrayTestImg(false, 10, 10,
		2);

	sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
	final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces
		.binary(ops, MapIIAndIIInplace.class, firstCopy, second, sub);
	map.run(firstCopy, second, firstCopy);
	map.run(first, secondCopy, secondCopy);

	assertImgSubEquals(first, second, firstCopy);
	assertImgSubEquals(first, second, secondCopy);

	// Expect exception when in2 has different dimensions
	thrown.expect(IllegalArgumentException.class);
	ops.op(MapIIAndIIInplace.class, first, secondDiffDims, sub);
}
 
Example 2
Source File: MapTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testIIAndIIInplaceParallel() {
	final Img<ByteType> first = generateByteArrayTestImg(true, 10, 10);
	final Img<ByteType> firstCopy = first.copy();
	final Img<ByteType> second = generateByteArrayTestImg(false, 10, 10);
	for (final ByteType px : second)
		px.set((byte) 1);
	final Img<ByteType> secondCopy = second.copy();
	final Img<ByteType> secondDiffDims = generateByteArrayTestImg(false, 10, 10,
		2);

	sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
	final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces
		.binary(ops, MapIIAndIIInplaceParallel.class, firstCopy, second, sub);
	map.run(firstCopy, second, firstCopy);
	map.run(first, secondCopy, secondCopy);

	assertImgSubEquals(first, second, firstCopy);
	assertImgSubEquals(first, second, secondCopy);

	// Expect exception when in2 has different dimensions
	thrown.expect(IllegalArgumentException.class);
	ops.op(MapIIAndIIInplaceParallel.class, first, secondDiffDims, sub);
}
 
Example 3
Source File: MapTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testIIAndIIInplaceParallelCellImg() {
	final Img<ByteType> first = generateByteTestCellImg(true, 40, 20);
	final Img<ByteType> firstCopy = first.copy();
	final Img<ByteType> second = generateByteTestCellImg(false, 40, 20);
	for (final ByteType px : second)
		px.set((byte) 1);
	final Img<ByteType> secondCopy = second.copy();

	sub = Inplaces.binary(ops, Ops.Math.Subtract.class, ByteType.class);
	final BinaryInplaceOp<? super Img<ByteType>, Img<ByteType>> map = Inplaces
		.binary(ops, MapIIAndIIInplaceParallel.class, firstCopy, second, sub);
	map.run(firstCopy, second, firstCopy);
	map.run(first, secondCopy, secondCopy);

	assertImgSubEquals(first, second, firstCopy);
	assertImgSubEquals(first, second, secondCopy);
}
 
Example 4
Source File: MapNeighborhoodTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final Iterable<ByteType> neighborhood, final ByteType center,
	final ByteType output)
{
	ByteType a = center;

	a.set((byte) 0);
	output.set((byte) 0);

	for (Iterator<ByteType> iter = neighborhood.iterator(); iter.hasNext(); iter
		.next())
	{
		output.inc();
		a.inc();
	}
}
 
Example 5
Source File: VolatileHierarchyProjectorPreMultiply.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set all pixels in target to 100% transparent zero, and mask to all Integer.MAX_VALUE.
 */
public void clearMask()
{
	for (final ByteType val : Views.iterable(mask))
		val.set(Byte.MAX_VALUE);
	numInvalidLevels = sources.size();
}
 
Example 6
Source File: VolatileHierarchyProjector.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set all pixels in target to 100% transparent zero, and mask to all
 * Integer.MAX_VALUE.
 */
public void clearMask()
{
	for ( final ByteType val : Views.iterable( mask ) )
		val.set( Byte.MAX_VALUE );
	numInvalidLevels = sources.size();
}
 
Example 7
Source File: ConvertTypes.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void compute(final C input, final ByteType output) {
	output.set((byte) input.getRealDouble());
}
 
Example 8
Source File: ConvertTypes.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void compute(final T input, final ByteType output) {
	output.set((byte) input.getIntegerLong());
}
 
Example 9
Source File: MapNeighborhoodTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void compute(final ByteType input, final ByteType output) {
	output.set((byte) (input.get() + 1));
}
 
Example 10
Source File: LoopTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void compute(final ByteType input, final ByteType output) {
	output.set(input);
	output.inc();
}
 
Example 11
Source File: JoinTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void compute(final ByteType input, final ByteType output) {
	output.set(input);
	output.inc();
}