File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -265,8 +265,8 @@ def save_masks(
265
265
266
266
# Generate a mask of objects with unique values
267
267
if unique :
268
- # Sort the masks by area in ascending order
269
- sorted_masks = sorted (masks , key = (lambda x : x ["area" ]), reverse = False )
268
+ # Sort the masks by area in descending order
269
+ sorted_masks = sorted (masks , key = (lambda x : x ["area" ]), reverse = True )
270
270
271
271
# Create an output image with the same size as the input image
272
272
objects = np .zeros (
@@ -276,9 +276,10 @@ def save_masks(
276
276
)
277
277
)
278
278
# Assign a unique value to each object
279
+ count = len (sorted_masks )
279
280
for index , ann in enumerate (sorted_masks ):
280
281
m = ann ["segmentation" ]
281
- objects [m ] = index + 1
282
+ objects [m ] = count - index
282
283
283
284
# Generate a binary mask
284
285
else :
Original file line number Diff line number Diff line change @@ -293,8 +293,8 @@ def save_masks(
293
293
294
294
# Generate a mask of objects with unique values
295
295
if unique :
296
- # Sort the masks by area in ascending order
297
- sorted_masks = sorted (masks , key = (lambda x : x ["area" ]), reverse = False )
296
+ # Sort the masks by area in descending order
297
+ sorted_masks = sorted (masks , key = (lambda x : x ["area" ]), reverse = True )
298
298
299
299
# Create an output image with the same size as the input image
300
300
objects = np .zeros (
@@ -304,9 +304,10 @@ def save_masks(
304
304
)
305
305
)
306
306
# Assign a unique value to each object
307
+ count = len (sorted_masks )
307
308
for index , ann in enumerate (sorted_masks ):
308
309
m = ann ["segmentation" ]
309
- objects [m ] = index + 1
310
+ objects [m ] = count - index
310
311
311
312
# Generate a binary mask
312
313
else :
You can’t perform that action at this time.
0 commit comments