Skip to content

Commit 74652c2

Browse files
committed
Utils example computes number of labels.
Fixes lucasb-eyer#13 continuation.
1 parent 42402df commit 74652c2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/utils_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
### Read images and annotation ###
2626
##################################
2727
img = cv2.imread(fn_im)
28-
labels = relabel_sequential(cv2.imread(fn_anno, 0))[0].flatten()
29-
M = 21 # 21 Classes to match the C++ example
28+
labels, _, _ = relabel_sequential(cv2.imread(fn_anno, 0))
29+
30+
# Compute the number of classes in the label image
31+
M = len(set(labels.flat))
3032

3133
###########################
3234
### Setup the CRF model ###

0 commit comments

Comments
 (0)