From 0bcb171240937c135a0d0d41a02fe2b6632a3243 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Thu, 13 Apr 2023 12:54:02 +0200 Subject: [PATCH] standalone cv2.imwrite: use uint8 / bilevel --- sbb_binarize/sbb_binarize.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbb_binarize/sbb_binarize.py b/sbb_binarize/sbb_binarize.py index 0c87ca0..5533b8d 100644 --- a/sbb_binarize/sbb_binarize.py +++ b/sbb_binarize/sbb_binarize.py @@ -255,9 +255,11 @@ class SbbBinarizer: img_fin = (res[:, :] == 0) * 255 img_last = img_last + img_fin - kernel = np.ones((5, 5), np.uint8) img_last[:, :][img_last[:, :] > 0] = 255 img_last = (img_last[:, :] == 0) * 255 if save: - cv2.imwrite(save, img_last) + cv2.imwrite(save, img_last.astype(np.uint8), [ + cv2.IMWRITE_PNG_BILEVEL, 1, + cv2.IMWRITE_JPEG_QUALITY, 100 + ]) return img_last