Skip to content

Commit

Permalink
correct bug that decreased the sizes of contours
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 25, 2024
1 parent b2001b9 commit 04c4792
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/ai/nets/samj/models/PythonMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ 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()
+ " sizes = []" + System.lineSeparator()
+ " 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()
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 04c4792

Please sign in to comment.