Skip to content

Commit

Permalink
remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 31, 2023
1 parent 67999a6 commit 7dbdd3c
Showing 1 changed file with 0 additions and 136 deletions.
136 changes: 0 additions & 136 deletions src/main/java/io/bioimage/modelrunner/numpy/DecodeNumpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,142 +408,6 @@ public static <T extends NativeType<T>> RandomAccessibleInterval<T> build(ByteBu
}
}

private static Img<ByteType> buildInt8(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< ByteType > factory = new ArrayImgFactory<>( new ByteType() );
final Img< ByteType > outputImg = (Img<ByteType>) factory.create(shape);
Cursor<ByteType> tensorCursor= outputImg.cursor();
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(buf.array()[flatPos]);
}
return outputImg;
}

private static Img<UnsignedByteType> buildUInt8(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< UnsignedByteType > factory = new ArrayImgFactory<>( new UnsignedByteType() );
final Img< UnsignedByteType > outputImg = (Img<UnsignedByteType>) factory.create(shape);
Cursor<UnsignedByteType> tensorCursor= outputImg.cursor();
int[] flatArr = ByteArrayUtils.toUInt8(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;
}

private static Img<ShortType> buildInt16(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< ShortType > factory = new ArrayImgFactory<>( new ShortType() );
final Img< ShortType > outputImg = (Img<ShortType>) factory.create(shape);
Cursor<ShortType> tensorCursor= outputImg.cursor();
short[] flatArr = ByteArrayUtils.toInt16(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;

}

private static Img<UnsignedShortType> buildUInt16(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< UnsignedShortType > factory = new ArrayImgFactory<>( new UnsignedShortType() );
final Img< UnsignedShortType > outputImg = (Img<UnsignedShortType>) factory.create(shape);
Cursor<UnsignedShortType> tensorCursor= outputImg.cursor();
int[] flatArr = ByteArrayUtils.toUInt16(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;
}

private static Img<IntType> buildInt32(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< IntType > factory = new ArrayImgFactory<>( new IntType() );
final Img< IntType > outputImg = (Img<IntType>) factory.create(shape);
Cursor<IntType> tensorCursor= outputImg.cursor();
int[] flatArr = ByteArrayUtils.toInt32(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;
}

private static Img<UnsignedIntType> buildUInt32(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< UnsignedIntType > factory = new ArrayImgFactory<>( new UnsignedIntType() );
final Img< UnsignedIntType > outputImg = (Img<UnsignedIntType>) factory.create(shape);
Cursor<UnsignedIntType> tensorCursor= outputImg.cursor();
long[] flatArr = ByteArrayUtils.toUInt32(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;
}

private static Img<LongType> buildInt64(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< LongType > factory = new ArrayImgFactory<>( new LongType() );
final Img< LongType > outputImg = (Img<LongType>) factory.create(shape);
Cursor<LongType> tensorCursor= outputImg.cursor();
long[] flatArr = ByteArrayUtils.toInt64(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;
}

private static Img<FloatType> buildFloat32(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< FloatType > factory = new ArrayImgFactory<>( new FloatType() );
final Img< FloatType > outputImg = (Img<FloatType>) factory.create(shape);
Cursor<FloatType> tensorCursor= outputImg.cursor();
float[] flatArr = ByteArrayUtils.toFloat32(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
float val = flatArr[flatPos];
tensorCursor.get().set(val);
}
return outputImg;
}

private static Img<DoubleType> buildFloat64(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< DoubleType > factory = new ArrayImgFactory<>( new DoubleType() );
final Img< DoubleType > outputImg = (Img<DoubleType>) factory.create(shape);
Cursor<DoubleType> tensorCursor= outputImg.cursor();
double[] flatArr = ByteArrayUtils.toFloat64(buf.array(), byteOrder);
while (tensorCursor.hasNext()) {
tensorCursor.fwd();
long[] cursorPos = tensorCursor.positionAsLongArray();
int flatPos = IndexingUtils.multidimensionalIntoFlatIndex(cursorPos, shape);
tensorCursor.get().set(flatArr[flatPos]);
}
return outputImg;
}

private static Img<ByteType> buildBoolean(ByteBuffer buf, ByteOrder byteOrder, long[] shape) {
buf.order(byteOrder);
final ArrayImgFactory< ByteType > factory = new ArrayImgFactory<>( new ByteType() );
Expand Down

0 comments on commit 7dbdd3c

Please sign in to comment.