use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class MapTest method testIIAndIIInplace.
@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);
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class MapTest method testIterable.
@Test
public void testIterable() {
final Img<ByteType> in = generateByteArrayTestImg(true, 10, 10);
final Op nullary = Computers.nullary(ops, Ops.Math.Zero.class, ByteType.class);
ops.run(MapNullaryIterable.class, in, nullary);
for (final ByteType ps : in) assertEquals(ps.get(), 0);
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class NonLinearFiltersTest method testVarianceFilter.
/**
* @see VarianceFilterOp
* @see DefaultVarianceFilter
*/
@Test
public void testVarianceFilter() {
ops.run(VarianceFilterOp.class, out, in, shape, oobFactory);
double sum = 0.0;
double sumSq = 0.0;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
sum += t.getRealDouble();
sumSq += t.getRealDouble() * t.getRealDouble();
}
assertEquals((byte) Util.round((sumSq - (sum * sum / 9)) / 8), out.firstElement().get());
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class NonLinearFiltersTest method testMaxFilter.
/**
* @see MaxFilterOp
* @see DefaultMaxFilter
*/
@Test
public void testMaxFilter() {
ops.run(MaxFilterOp.class, out, in, shape, oobFactory);
byte max = Byte.MIN_VALUE;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
max = (byte) Math.max(t.getInteger(), max);
}
assertEquals(out.firstElement().get(), max);
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class NonLinearFiltersTest method testMinFilter.
/**
* @see MinFilterOp
* @see DefaultMinFilter
*/
@Test
public void testMinFilter() {
ops.run(MinFilterOp.class, out, in, shape, oobFactory);
byte min = Byte.MAX_VALUE;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
min = (byte) Math.min(t.getInteger(), min);
}
assertEquals(min, out.firstElement().get());
}
Aggregations