Skip to content

Commit

Permalink
test imglib2 push and pull
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Aug 8, 2024
1 parent d11297d commit ce9ff1d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/test/java/TestImgLibPushAndPull.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.junit.jupiter.api.Test;

import net.imglib2.Cursor;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.type.numeric.integer.IntType;
import net.clesperanto.core.ArrayJ;
import net.clesperanto.core.DeviceJ;
import net.clesperanto.imglib2.ImgLib2Converters;

import static org.junit.jupiter.api.Assertions.*;


public class TestImgLibPushAndPull {

@Test
public void testImgLibPushAndPull() {
int[] flatVals = new int[18];
for (int i = 0; i < flatVals.length; i ++)
flatVals[i] = i;
RandomAccessibleInterval<IntType> inputImg = ArrayImgs.ints(flatVals, new long[] {3, 3, 2});


DeviceJ device = DeviceJ.getDefaultDevice();
ArrayJ in = ImgLib2Converters.copyImgLib2ToArrayJ(inputImg, device, "buffer");
RandomAccessibleInterval<IntType> outputImg = ImgLib2Converters.copyArrayJToImgLib2(in);

Cursor<IntType> inCursor = inputImg.cursor();
Cursor<IntType> outCursor = outputImg.cursor();

while (inCursor.hasNext()) {
assertEquals(inCursor.get().get(), outCursor.get().get());
inCursor.next();
outCursor.next();
}
}
}

0 comments on commit ce9ff1d

Please sign in to comment.