From 04c479242c5b6c1fe81f23160d0f9539f4723dc2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 25 Oct 2024 18:26:35 +0200 Subject: [PATCH] correct bug that decreased the sizes of contours --- src/main/java/ai/nets/samj/models/PythonMethods.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/ai/nets/samj/models/PythonMethods.java b/src/main/java/ai/nets/samj/models/PythonMethods.java index e5b31d7..3149de5 100644 --- a/src/main/java/ai/nets/samj/models/PythonMethods.java +++ b/src/main/java/ai/nets/samj/models/PythonMethods.java @@ -79,8 +79,8 @@ public class PythonMethods { + " #" + System.lineSeparator() + " return x_coords,y_coords" + System.lineSeparator() + "" + System.lineSeparator() - + "def get_polygons_from_binary_mask(sam_result, at_least_of_this_size = 3, only_biggest=False):" + System.lineSeparator() - + " labels = measure.regionprops( measure.label(sam_result,connectivity=1) )" + System.lineSeparator() + + "def get_polygons_from_binary_mask(sam_result, at_least_of_this_size = 6, only_biggest=False):" + System.lineSeparator() + + " labels = measure.regionprops( measure.label(sam_result > 0,connectivity=1) )" + System.lineSeparator() + " x_contours = []" + System.lineSeparator() + " y_contours = []" + System.lineSeparator() + " rles = []" + System.lineSeparator() @@ -88,7 +88,6 @@ public class PythonMethods { + " for obj in labels:" + System.lineSeparator() + " if obj.num_pixels >= at_least_of_this_size:" + System.lineSeparator() + " x_coords,y_coords = trace_contour(obj.image, obj.num_pixels, obj.bbox[1],obj.bbox[0])" + System.lineSeparator() - + " np.save('/home/carlos/git/test.npy', obj.image)" + System.lineSeparator() + " rles.append(encode_rle(obj.image))" + System.lineSeparator() + " x_contours.append(x_coords)" + System.lineSeparator() + " y_contours.append(y_coords)" + System.lineSeparator() @@ -141,7 +140,7 @@ public class PythonMethods { + " " + System.lineSeparator() + " # Only encode runs of 1s" + System.lineSeparator() + " if binary[start] == 1:" + System.lineSeparator() - + " rle.extend([start, length])" + System.lineSeparator() + + " rle.extend([int(start), int(length)])" + System.lineSeparator() + " " + System.lineSeparator() + " return rle" + System.lineSeparator() + "globals()['encode_rle'] = encode_rle" + System.lineSeparator();