diff --git a/src/main/java/ai/nets/samj/models/EfficientSamJ.java b/src/main/java/ai/nets/samj/models/EfficientSamJ.java index 956bad5..e0913e1 100644 --- a/src/main/java/ai/nets/samj/models/EfficientSamJ.java +++ b/src/main/java/ai/nets/samj/models/EfficientSamJ.java @@ -329,10 +329,10 @@ protected void processBoxWithSAM(boolean returnAll) { void adaptImageToModel(final RandomAccessibleInterval ogImg, RandomAccessibleInterval targetImg) { if (ogImg.numDimensions() == 3 && ogImg.dimensionsAsLongArray()[2] == 3) { for (int i = 0; i < 3; i ++) - RealTypeConverters.copyFromTo( ImgLib2SAMUtils.normalizedView(Views.hyperSlice(ogImg, 2, i), this.debugPrinter), Views.hyperSlice(targetImg, 2, i) ); + RealTypeConverters.copyFromTo( ImgLib2Utils.normalizedView(Views.hyperSlice(ogImg, 2, i), this.debugPrinter), Views.hyperSlice(targetImg, 2, i) ); } else if (ogImg.numDimensions() == 3 && ogImg.dimensionsAsLongArray()[2] == 1) { debugPrinter.printText("CONVERTED 1 CHANNEL IMAGE INTO 3 TO BE FEEDED TO SAMJ"); - IntervalView resIm = Views.interval( Views.expandMirrorDouble(ImgLib2SAMUtils.normalizedView(ogImg, this.debugPrinter), new long[] {0, 0, 2}), + IntervalView resIm = Views.interval( Views.expandMirrorDouble(ImgLib2Utils.normalizedView(ogImg, this.debugPrinter), new long[] {0, 0, 2}), Intervals.createMinMax(new long[] {0, 0, 0, ogImg.dimensionsAsLongArray()[0], ogImg.dimensionsAsLongArray()[1], 2}) ); RealTypeConverters.copyFromTo( resIm, targetImg ); } else if (ogImg.numDimensions() == 2) { @@ -377,7 +377,7 @@ private & NativeType> void checkImageIsFine(RandomAcce @Override protected & NativeType> void createSHMArray(RandomAccessibleInterval imShared) { - RandomAccessibleInterval imageToBeSent = ImgLib2SAMUtils.reescaleIfNeeded(imShared); + RandomAccessibleInterval imageToBeSent = ImgLib2Utils.reescaleIfNeeded(imShared); long[] dims = imageToBeSent.dimensionsAsLongArray(); shma = SharedMemoryArray.buildMemorySegmentForImage(new long[] {dims[0], dims[1], dims[2]}, new FloatType()); adaptImageToModel(imageToBeSent, shma.getSharedRAI()); diff --git a/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java b/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java index a383f9c..34ed86e 100644 --- a/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java +++ b/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java @@ -311,7 +311,7 @@ protected void createEncodeImageScript() { @Override protected & NativeType> void createSHMArray(RandomAccessibleInterval imShared) { - RandomAccessibleInterval imageToBeSent = ImgLib2SAMUtils.reescaleIfNeeded(imShared); + RandomAccessibleInterval imageToBeSent = ImgLib2Utils.reescaleIfNeeded(imShared); long[] dims = imageToBeSent.dimensionsAsLongArray(); shma = SharedMemoryArray.buildMemorySegmentForImage(new long[] {dims[0], dims[1], dims[2]}, new UnsignedByteType()); adaptImageToModel(imageToBeSent, shma.getSharedRAI()); @@ -432,12 +432,12 @@ public static List getListOfSupportedEfficientViTSAM(){ void adaptImageToModel(RandomAccessibleInterval ogImg, RandomAccessibleInterval targetImg) { if (ogImg.numDimensions() == 3 && ogImg.dimensionsAsLongArray()[2] == 3) { for (int i = 0; i < 3; i ++) - RealTypeConverters.copyFromTo( ImgLib2SAMUtils.convertViewToRGB(Views.hyperSlice(ogImg, 2, i), this.debugPrinter), + RealTypeConverters.copyFromTo( ImgLib2Utils.convertViewToRGB(Views.hyperSlice(ogImg, 2, i), this.debugPrinter), Views.hyperSlice(targetImg, 2, i) ); } else if (ogImg.numDimensions() == 3 && ogImg.dimensionsAsLongArray()[2] == 1) { debugPrinter.printText("CONVERTED 1 CHANNEL IMAGE INTO 3 TO BE FEEDED TO SAMJ"); IntervalView resIm = - Views.interval( Views.expandMirrorDouble(ImgLib2SAMUtils.convertViewToRGB(ogImg, this.debugPrinter), new long[] {0, 0, 2}), + Views.interval( Views.expandMirrorDouble(ImgLib2Utils.convertViewToRGB(ogImg, this.debugPrinter), new long[] {0, 0, 2}), Intervals.createMinMax(new long[] {0, 0, 0, ogImg.dimensionsAsLongArray()[0], ogImg.dimensionsAsLongArray()[1], 2}) ); RealTypeConverters.copyFromTo( resIm, targetImg ); } else if (ogImg.numDimensions() == 2) { diff --git a/src/main/java/ai/nets/samj/models/ImgLib2SAMUtils.java b/src/main/java/ai/nets/samj/models/ImgLib2Utils.java similarity index 99% rename from src/main/java/ai/nets/samj/models/ImgLib2SAMUtils.java rename to src/main/java/ai/nets/samj/models/ImgLib2Utils.java index e701556..6b1cc1a 100644 --- a/src/main/java/ai/nets/samj/models/ImgLib2SAMUtils.java +++ b/src/main/java/ai/nets/samj/models/ImgLib2Utils.java @@ -14,7 +14,7 @@ import net.imglib2.util.Util; import net.imglib2.view.Views; -public class ImgLib2SAMUtils { +public class ImgLib2Utils { /** * Get the maximum and minimum pixel values of an {@link IterableInterval}