Skip to content

Commit 5d47833

Browse files
committed
Allow a background pixel of [0,0,1,1] to be defined, and if it
exists, skip it. This is to allow sparse pixelmaps which has empty space between bounding boxes/superpixels
1 parent 95ae284 commit 5d47833

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

superpixel_classification/SuperpixelClassification/SuperpixelClassificationBase.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ def createFeaturesForItem(self, gc, item, elem, featureFolderId, fileName, patch
351351

352352
num_values = len(elem['values'])
353353
labeled_samples = set([i for i, x in enumerate(elem['values']) if x > 0])
354-
unlabeled_samples = [i for i, x in enumerate(elem['values']) if x == 0]
354+
# background is used if we have a bounding box of 1 pixel in top left corner that is unlabeled. We do not want to extract features for that
355+
has_background = elem['user']['bbox'][:4] == [0,0,1,1]
356+
start_index = 1 if has_background else 0
357+
unlabeled_samples = [i for i, x in enumerate(elem['values'][start_index:], start=start_index) if x == 0]
358+
355359
if num_values - len(labeled_samples) > cutoff:
356360
# only select a subset of unlabeled samples, i.e., prune the feature list
357361
random.shuffle(unlabeled_samples)

0 commit comments

Comments
 (0)