Skip to content

Commit

Permalink
correct casting
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 12, 2023
1 parent 586e37c commit ebd21fe
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/io/bioimage/modelrunner/tensor/ImgLib2ToArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.imglib2.Cursor;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.NativeType;
import net.imglib2.type.Type;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.ByteType;
import net.imglib2.type.numeric.integer.IntType;
Expand All @@ -34,6 +33,7 @@
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.Cast;
import net.imglib2.util.Util;
import net.imglib2.view.Views;

Expand Down Expand Up @@ -86,23 +86,23 @@ public static < T extends RealType< T > & NativeType< T > > Object build(Tensor<
public static < T extends RealType< T > & NativeType< T > > Object build(RandomAccessibleInterval<T> rai)
{
if (Util.getTypeFromInterval(rai) instanceof ByteType) {
return buildInt8((RandomAccessibleInterval<ByteType>) rai);
return buildInt8(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof UnsignedByteType) {
return buildUint8((RandomAccessibleInterval<UnsignedByteType>) rai);
return buildUint8(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof ShortType) {
return buildInt16((RandomAccessibleInterval<ShortType>) rai);
return buildInt16(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof UnsignedShortType) {
return buildUint16((RandomAccessibleInterval<UnsignedShortType>) rai);
return buildUint16(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof IntType) {
return buildInt32((RandomAccessibleInterval<IntType>) rai);
return buildInt32(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof UnsignedIntType) {
return buildUint32((RandomAccessibleInterval<UnsignedIntType>) rai);
return buildUint32(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof LongType) {
return buildInt64((RandomAccessibleInterval<LongType>) rai);
return buildInt64(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof FloatType) {
return buildFloat32((RandomAccessibleInterval<FloatType>) rai);
return buildFloat32(Cast.unchecked(rai));
} else if (Util.getTypeFromInterval(rai) instanceof DoubleType) {
return buildFloat64((RandomAccessibleInterval<DoubleType>) rai);
return buildFloat64(Cast.unchecked(rai));
} else {
throw new IllegalArgumentException("The image has an unsupported type: " + Util.getTypeFromInterval(rai).getClass().toString());
}
Expand Down

0 comments on commit ebd21fe

Please sign in to comment.