use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class DefaultCoarsenessFeature method mean.
/**
* Apply mean filter with given size of reactangle shape
*
* @param input
* Input image
* @param i
* Size of rectangle shape
* @return Filered mean image
*/
@SuppressWarnings("unchecked")
private Img<I> mean(final RandomAccessibleInterval<I> input, final int i) {
long[] dims = new long[input.numDimensions()];
input.dimensions(dims);
final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval(dims))];
Img<I> meanImg = (Img<I>) ArrayImgs.unsignedBytes(array, dims);
OutOfBoundsMirrorFactory<ByteType, Img<ByteType>> oobFactory = new OutOfBoundsMirrorFactory<>(Boundary.SINGLE);
ops().run(MeanFilterOp.class, meanImg, input, new RectangleShape(i, true), oobFactory);
return meanImg;
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class InvertTest method testByteTypeInvert.
@Test
public void testByteTypeInvert() {
final Img<ByteType> inByteType = generateByteArrayTestImg(true, 5, 5);
final Img<ByteType> outByteType = inByteType.factory().create(inByteType, new ByteType());
assertDefaultInvert(inByteType, outByteType);
assertDefaultInvertMinMaxProvided(inByteType, outByteType, new ByteType((byte) 0), new ByteType((byte) 0));
assertDefaultInvertMinMaxProvided(inByteType, outByteType, new ByteType((byte) 20), new ByteType((byte) 10));
assertDefaultInvertMinMaxProvided(inByteType, outByteType, new ByteType((byte) 256), new ByteType((byte) 256));
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class NormalizeTest method testNormalize.
@Test
public void testNormalize() {
Img<ByteType> in = generateByteArrayTestImg(true, 5, 5);
Img<ByteType> out = in.factory().create(in, new ByteType());
ops.run(NormalizeIIComputer.class, out, in);
final Pair<ByteType, ByteType> minMax2 = ops.stats().minMax(out);
assertEquals(minMax2.getA().get(), Byte.MIN_VALUE);
assertEquals(minMax2.getB().get(), Byte.MAX_VALUE);
final IterableInterval<ByteType> lazyOut = ops.image().normalize(in);
final IterableInterval<ByteType> notLazyOut = ops.image().normalize(in, null, null, null, null, false);
final Cursor<ByteType> outCursor = out.cursor();
final Cursor<ByteType> lazyCursor = lazyOut.cursor();
final Cursor<ByteType> notLazyCursor = notLazyOut.cursor();
while (outCursor.hasNext()) {
assertEquals(outCursor.next().get(), lazyCursor.next().get());
assertEquals(outCursor.get().get(), notLazyCursor.next().get());
}
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class MapNeighborhoodTest method testMapNeighborhoodsAccess.
/**
* Test if every neighborhood pixel of the image was really accessed during
* the map operation.
*
* @see DefaultMapNeighborhood
*/
@Test
public void testMapNeighborhoodsAccess() {
final Op mapOp = ops.op(DefaultMapNeighborhood.class, out, in, new RectangleShape(1, false), new CountNeighbors());
mapOp.run();
for (final ByteType t : out) {
assertEquals(9, t.get());
}
}
use of net.imglib2.type.numeric.integer.ByteType in project imagej-ops by imagej.
the class MapNeighborhoodTest method testMapNeighborhoodsWithCenterAccess.
/**
* Test if every neighborhood pixel of the image was really accessed during
* the map operation.
*
* @see MapNeighborhoodWithCenter
*/
@Test
public void testMapNeighborhoodsWithCenterAccess() {
final Op mapOp = ops.op(MapNeighborhoodWithCenter.class, out, in, new RectangleShape(1, false), new CountNeighborsWithCenter());
mapOp.run();
for (final ByteType t : out) {
assertEquals(9, t.get());
}
for (final ByteType t : in) {
assertEquals(9, t.get());
}
}
Aggregations