Skip to content

Commit

Permalink
Ensure empty label sets don't throw exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gselzer authored and ctrueden committed Apr 20, 2022
1 parent 693788a commit b658367
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ private <S, T, I extends IntegerType<I>> ImgLabeling<T, I> buildImgLabelingAndIm
}

private <T, S> void createLabelsets(LabelingMapping<T> labelingMapping, LabelingData<T, S> labelingData) {
if (labelingMapping.getLabels().stream().findFirst().get() instanceof Integer) {
Optional<T> optional = labelingMapping.getLabels().stream().findFirst();
if (optional.isPresent() && optional.get() instanceof Integer) {
Map<String, Set<Integer>> labels = new HashMap<>();
for (int i = 0; i < labelingMapping.numSets(); i++) {
labels.put(Integer.toString(i), (Set<Integer>) labelingMapping.labelsAtIndex(i));
Expand Down

0 comments on commit b658367

Please sign in to comment.