use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class MapTest method testIIAndIIInplaceParallel.
@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);
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class MapTest method testIICellImg.
// -- Test with CellImg --
@Test
public void testIICellImg() {
final Img<ByteType> in = generateByteTestCellImg(true, 40, 20);
final Op nullary = Computers.nullary(ops, Ops.Math.Zero.class, ByteType.class);
ops.run(MapNullaryII.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 MeanTest method testMean.
@Test
public void testMean() {
final Img<ByteType> image = generateByteArrayTestImg(true, 40, 50);
final DoubleType mean = new DoubleType();
ops.run(IterableMean.class, mean, image);
assertEquals(1.0 / 15.625, mean.get(), 0.0);
Cursor<ByteType> c = image.cursor();
// this time lets just make every value 100
while (c.hasNext()) {
c.fwd();
c.get().setReal(100.0);
}
ops.run(IterableMean.class, mean, image);
// the mean should be 100
assertEquals(100.0, mean.get(), 0.0);
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class ConcatenateViewTest method concatenateWithAccessModeTest.
@Test
public void concatenateWithAccessModeTest() {
final List<RandomAccessibleInterval<ByteType>> intervals = createIntervals(img, divider, axis);
for (final StackAccessMode mode : StackAccessMode.values()) {
final RandomAccessibleInterval<ByteType> cat1 = Views.concatenate(axis, mode, intervals);
final RandomAccessibleInterval<ByteType> cat2 = ops.transform().concatenateView(intervals, axis, mode);
testEqual(cat1, cat2);
}
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class NonLinearFiltersTest method testMeanFilter.
/**
* @see MeanFilterOp
* @see DefaultMeanFilter
*/
@Test
public void testMeanFilter() {
ops.run(MeanFilterOp.class, out, in, shape, oobFactory);
double sum = 0.0;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
sum += t.getRealDouble();
}
assertEquals(Util.round(sum / 9.0), out.firstElement().get());
}
Aggregations