Java Code Examples for net.imglib2.img.array.ArrayImgs#bytes()
The following examples show how to use
net.imglib2.img.array.ArrayImgs#bytes() .
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: DefaultBilateralTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testArrayToCellImg() { final byte[] data = { 7, 8, 9, 1, 2, 3, 7, 9, 8, 1, 3, 2, 8, 7, 9, 2, 1, 3, 8, 9, 7, 2, 3, 1, 9, 7, 8, 3, 1, 2, 9, 8, 7, 3, 2, 1 }; final Img<ByteType> in = ArrayImgs.bytes(data, 6, 6); final Img<ByteType> out = generateByteArrayTestImg(false, 6, 6); final Img<ByteType> cellOut = generateByteTestCellImg(false, 6, 6); ops.run(DefaultBilateral.class, out, in, 15, 5, 2); ops.run(DefaultBilateral.class, cellOut, in, 15, 5, 2); Cursor<ByteType> cout = out.cursor(); Cursor<ByteType> cCellOut = cellOut.cursor(); while (cout.hasNext()) { byte expected = cout.next().get(); byte actual = cCellOut.next().get(); assertEquals(expected, actual); } }
Example 2
Source File: MapCompatibleTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@SuppressWarnings("unchecked") @BeforeClass public static void init() { in1II = ArrayImgs.bytes(2, 2); in2II = ArrayImgs.bytes(2, 2); outII = ArrayImgs.bytes(2, 2); in1LargeII = ArrayImgs.bytes(3, 3); in2LargeII = ArrayImgs.bytes(3, 3); outLargeII = ArrayImgs.bytes(3, 3); in1RAI = (RandomAccessibleInterval<ByteType>) in1II; in2RAI = (RandomAccessibleInterval<ByteType>) in2II; outRAI = (RandomAccessibleInterval<ByteType>) outII; in1LargeRAI = (RandomAccessibleInterval<ByteType>) in1LargeII; in2LargeRAI = (RandomAccessibleInterval<ByteType>) in2LargeII; outLargeRAI = (RandomAccessibleInterval<ByteType>) outLargeII; }
Example 3
Source File: DefaultBilateralTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testNegatives() { final byte[] data = { -7, -8, -9, -1, -2, -3, -7, -9, -8, -1, -3, -2, -8, -7, -9, -2, -1, -3, -8, -9, -7, -2, -3, -1, -9, -7, -8, -3, -1, -2, -9, -8, -7, -3, -2, -1 }; final Img<ByteType> in = ArrayImgs.bytes(data, 6, 6); final Img<ByteType> out = generateByteArrayTestImg(false, 6, 6); ops.run(DefaultBilateral.class, out, in, 15, 5, 2); final byte[] expected = { -8, -7, -6, -4, -3, -2, -8, -7, -6, -4, -3, -2, -8, -7, -6, -4, -3, -2, -8, -7, -6, -4, -3, -2, -8, -7, -6, -4, -3, -2, -8, -7, -6, -4, -3, -2 }; Cursor<ByteType> cout = out.cursor(); for (int i = 0; i < expected.length; i++) { assertEquals(cout.next().get(), expected[i]); } }
Example 4
Source File: LocalThresholdTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImgLarge() { final long[] dims = new long[] { 3, 3 }; final byte[] array = new byte[9]; array[0] = (byte) 40; array[1] = (byte) 40; array[2] = (byte) 20; array[3] = (byte) 40; array[4] = (byte) 40; array[5] = (byte) 20; array[6] = (byte) 20; array[7] = (byte) 20; array[8] = (byte) 100; return ArrayImgs.bytes(array, dims); }
Example 5
Source File: DefaultBilateralTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testMath() { final byte[] data = { 7, 4, 9, 1 }; final Img<ByteType> in = ArrayImgs.bytes(data, 2, 2); final Img<ByteType> out = generateByteArrayTestImg(false, 2, 2); ops.run(DefaultBilateral.class, out, in, 15, 5, 1); Cursor<ByteType> cout = out.cursor(); final byte[] expected = { 5, 5, 5, 5 }; int counter = 0; while (cout.hasNext()) { byte actual = cout.next().get(); assertEquals(expected[counter++], actual); } }
Example 6
Source File: SliceTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Override @Before public void setUp() { context = new Context(OpService.class); ops = context.service(OpService.class); in = ArrayImgs.bytes(20, 20, 21); out = ArrayImgs.bytes(20, 20, 21); // fill array img with values (plane position = value in px); for (final Cursor<ByteType> cur = in.cursor(); cur.hasNext();) { cur.fwd(); cur.get().set((byte) cur.getIntPosition(2)); } }
Example 7
Source File: SliceTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
private void testXYZCropping(int t) { Img<ByteType> inSequence = ArrayImgs.bytes(20, 20, 21, t); ArrayImg<ByteType, ByteArray> outSequence = ArrayImgs.bytes(20, 20, 21, t); // fill array img with values (plane position = value in px); for (final Cursor<ByteType> cur = inSequence.cursor(); cur.hasNext();) { cur.fwd(); cur.get().set((byte) cur.getIntPosition(2)); } // selected interval XYZ final int[] xyAxis = new int[] { 0, 1, 2 }; ops.run(SliceRAI2RAI.class, outSequence, inSequence, new DummyOp(), xyAxis); for (final Cursor<ByteType> cur = outSequence.cursor(); cur.hasNext();) { cur.fwd(); assertEquals(cur.getIntPosition(2), cur.get().getRealDouble(), 0); } }
Example 8
Source File: SliceTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testNonZeroMinimumInterval() { Img<ByteType> img3D = ArrayImgs.bytes(50, 50, 3); IntervalView<ByteType> interval2D = Views.interval(img3D, new FinalInterval(new long[] { 25, 25, 2 }, new long[] { 35, 35, 2 })); final int[] xyAxis = new int[] { 0, 1 }; // iterate through every slice, should return a single // RandomAccessibleInterval<?> from 25, 25, 2 to 35, 35, 2 final SlicesII<ByteType> hyperSlices = new SlicesII<>(interval2D, xyAxis, true); final Cursor<RandomAccessibleInterval<ByteType>> c = hyperSlices.cursor(); int i = 0; while (c.hasNext()) { c.next(); i++; } assertEquals(1, i); }
Example 9
Source File: VolatileHierarchyProjectorPreMultiply.java From paintera with GNU General Public License v2.0 | 6 votes |
public VolatileHierarchyProjectorPreMultiply( final List<? extends RandomAccessible<A>> sources, final Converter<? super A, ARGBType> converter, final RandomAccessibleInterval<ARGBType> target, final int numThreads, final ExecutorService executorService) { this( sources, converter, target, ArrayImgs.bytes(Intervals.dimensionsAsLongArray(target)), numThreads, executorService ); }
Example 10
Source File: SquareIntegralImgTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
private Img<ByteType> generateKnownSquareIntegralImage() { final long[] dims = new long[] { 3, 3 }; final byte[] array = new byte[9]; array[0] = (byte) 16; array[1] = (byte) 32; array[2] = (byte) 36; array[3] = (byte) 32; array[4] = (byte) 64; array[5] = (byte) 72; array[6] = (byte) 36; array[7] = (byte) 72; array[8] = (byte) 116; Img<ByteType> bytes = ArrayImgs.bytes(array, dims); return bytes; }
Example 11
Source File: SquareIntegralImgTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImg() { final long[] dims = new long[] { 3, 3 }; final byte[] array = new byte[9]; array[0] = (byte) 4; array[1] = (byte) 4; array[2] = (byte) 2; array[3] = (byte) 4; array[4] = (byte) 4; array[5] = (byte) 2; array[6] = (byte) 2; array[7] = (byte) 2; array[8] = (byte) 6; return ArrayImgs.bytes(array, dims); }
Example 12
Source File: IntegralCursorTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImg() { final long[] dims = new long[] { 3, 3 }; final byte[] array = new byte[9]; array[0] = (byte) 1; array[1] = (byte) 2; array[2] = (byte) 3; array[3] = (byte) 4; array[4] = (byte) 5; array[5] = (byte) 6; array[6] = (byte) 7; array[7] = (byte) 8; array[8] = (byte) 9; return ArrayImgs.bytes(array, dims); }
Example 13
Source File: IntegralImgTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
public ArrayImg<ByteType, ByteArray> generateKnownByteArrayTestImgLarge() { final long[] dims = new long[] { 3, 3 }; final byte[] array = new byte[9]; array[0] = (byte) 40; array[1] = (byte) 40; array[2] = (byte) 20; array[3] = (byte) 40; array[4] = (byte) 40; array[5] = (byte) 20; array[6] = (byte) 20; array[7] = (byte) 20; array[8] = (byte) 100; return ArrayImgs.bytes(array, dims); }
Example 14
Source File: DefaultBilateralTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testBigImage() { final byte[] data = { 7, 8, 9, 1, 2, 3, 7, 9, 8, 1, 3, 2, 8, 7, 9, 2, 1, 3, 8, 9, 7, 2, 3, 1, 9, 7, 8, 3, 1, 2, 9, 8, 7, 3, 2, 1 }; final Img<ByteType> in = ArrayImgs.bytes(data, 6, 6); final Img<ByteType> out = generateByteArrayTestImg(false, 6, 6); ops.run(DefaultBilateral.class, out, in, 15, 5, 2); final byte[] expected = { 8, 7, 6, 4, 3, 2, 8, 7, 6, 4, 3, 2, 8, 7, 6, 4, 3, 2, 8, 7, 6, 4, 3, 2, 8, 7, 6, 4, 3, 2, 8, 7, 6, 4, 3, 2 }; Cursor<ByteType> cout = out.cursor(); for (int i = 0; i < expected.length; i++) { assertEquals(cout.next().get(), expected[i]); } }
Example 15
Source File: AbstractOpTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
public ArrayImg<ByteType, ByteArray> generateByteArrayTestImg( final boolean fill, final long... dims) { final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval( dims))]; if (fill) { seed = 17; for (int i = 0; i < array.length; i++) { array[i] = (byte) pseudoRandom(); } } return ArrayImgs.bytes(array, dims); }
Example 16
Source File: DefaultBilateralTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testGaussianVsBilateral() { final byte[] data = { 7, 8, 9, 1, 2, 3, 7, 9, 8, 1, 3, 2, 8, 7, 9, 2, 1, 3, 8, 9, 7, 2, 3, 1, 9, 7, 8, 3, 1, 2, 9, 8, 7, 3, 2, 1 }; final Img<ByteType> in = ArrayImgs.bytes(data, 6, 6); final Img<ByteType> gaussOut = generateByteArrayTestImg(false, 6, 6); final Img<ByteType> bilateralOut = generateByteTestCellImg(false, 6, 6); ops.run(DefaultBilateral.class, bilateralOut, in, 15, 5, 2); final double sigma = 5; ops.run(GaussRAISingleSigma.class, gaussOut, in, sigma); assertEquals(areCongruent(gaussOut, bilateralOut, 0), false); }
Example 17
Source File: Tamura2dFeatureTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testCoarsenessFeature() { assertEquals(Ops.Tamura.Coarseness.NAME, 43.614, ((RealType<?>) ops.run( DefaultCoarsenessFeature.class, random)).getRealDouble(), 1e-3); // NB: according to the implementation, this 2x2 image should have exactly 0 // coarseness. byte[] arr = new byte[] {0, -1, 0, 0}; Img<ByteType> in = ArrayImgs.bytes(arr, 2, 2); assertEquals(Ops.Tamura.Coarseness.NAME, 0.0, ((RealType<?>) ops.run( DefaultCoarsenessFeature.class, in)).getRealDouble(), 0.0); }
Example 18
Source File: VolatileHierarchyProjector.java From paintera with GNU General Public License v2.0 | 5 votes |
public VolatileHierarchyProjector( final List< ? extends RandomAccessible< A > > sources, final Converter< ? super A, B > converter, final RandomAccessibleInterval< B > target, final int numThreads, final ExecutorService executorService ) { this( sources, converter, target, ArrayImgs.bytes( Intervals.dimensionsAsLongArray( target ) ), numThreads, executorService ); }
Example 19
Source File: FillTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 4 votes |
@Override @Before public void setUp() { super.setUp(); out = ArrayImgs.bytes(10, 10); }
Example 20
Source File: CropTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 4 votes |
@Override @Before public void setUp() { super.setUp(); in = ArrayImgs.bytes(20, 20, 20); }