From 50b1a7524754392ea7d154ff71a1e087c1cb06a3 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Sat, 20 Apr 2024 18:43:27 +0200 Subject: [PATCH] correct small details --- src/main/java/ai/nets/samj/AbstractSamJ.java | 8 +++++--- src/main/java/ai/nets/samj/EfficientSamJ.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/ai/nets/samj/AbstractSamJ.java b/src/main/java/ai/nets/samj/AbstractSamJ.java index c0ab770..b3ae219 100644 --- a/src/main/java/ai/nets/samj/AbstractSamJ.java +++ b/src/main/java/ai/nets/samj/AbstractSamJ.java @@ -50,7 +50,9 @@ public class AbstractSamJ { protected static double UPPER_REENCODE_THRESH = 1.1; - public static long MAX_ENCODED_IMAGE_SIZE = 2048; + public static long MAX_ENCODED_AREA_RS = 1024; + + public static long MAX_ENCODED_SIDE = MAX_ENCODED_AREA_RS * 3; protected static long ENCODE_MARGIN = 20; @@ -232,11 +234,11 @@ RandomAccessibleInterval convertViewToRGB(final RandomAccessib protected static & NativeType> RandomAccessibleInterval reescaleIfNeeded(RandomAccessibleInterval rai) { if ((rai.dimensionsAsLongArray()[0] > rai.dimensionsAsLongArray()[1]) - && (rai.dimensionsAsLongArray()[0] > MAX_ENCODED_IMAGE_SIZE)) { + && (rai.dimensionsAsLongArray()[0] > MAX_ENCODED_AREA_RS)) { // TODO reescale return rai; } else if ((rai.dimensionsAsLongArray()[0] < rai.dimensionsAsLongArray()[1]) - && (rai.dimensionsAsLongArray()[1] > MAX_ENCODED_IMAGE_SIZE)) { + && (rai.dimensionsAsLongArray()[1] > MAX_ENCODED_SIDE)) { // TODO reescale return rai; } else { diff --git a/src/main/java/ai/nets/samj/EfficientSamJ.java b/src/main/java/ai/nets/samj/EfficientSamJ.java index d23ee0f..2d4b658 100644 --- a/src/main/java/ai/nets/samj/EfficientSamJ.java +++ b/src/main/java/ai/nets/samj/EfficientSamJ.java @@ -275,8 +275,10 @@ void updateImage(RandomAccessibleInterval rai) throws IOException, RuntimeExc private & NativeType> void addImage(RandomAccessibleInterval rai) throws IOException, RuntimeException, InterruptedException{ - if (rai.dimensionsAsLongArray()[0] * rai.dimensionsAsLongArray()[1] > MAX_ENCODED_IMAGE_SIZE * MAX_ENCODED_IMAGE_SIZE) { + if (rai.dimensionsAsLongArray()[0] * rai.dimensionsAsLongArray()[1] > MAX_ENCODED_AREA_RS * MAX_ENCODED_AREA_RS + || rai.dimensionsAsLongArray()[0] > MAX_ENCODED_SIDE || rai.dimensionsAsLongArray()[1] > MAX_ENCODED_SIDE) { this.targetDims = new long[] {0, 0, 0}; + return; } this.script = ""; sendImgLib2AsNp(rai);