fixing the --threshold setting (given in percent)

This commit is contained in:
Philipp Klaus
2016-12-13 15:51:58 +01:00
parent 4d842f1fd6
commit 9da7e0ba28
+3 -1
View File
@@ -89,7 +89,9 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, **kwargs):
im = new_im
else:
raise NotImplementedError("Label kind %s not implemented yet." % label_specs['kind'])
im = im.point(lambda p: p > threshold and 255, mode="1")
threshold = min(255, max(0, int(threshold/100.0 * 255))) # from percent to pixel val
im = im.point(lambda x: 0 if x < threshold else 255, mode="1")
try:
qlr.add_switch_mode()