From 1b21fdba0e9c1e90a247c8aa1232c03f3ab7da34 Mon Sep 17 00:00:00 2001 From: Eric Bezzam Date: Wed, 29 Nov 2023 14:21:13 +0100 Subject: [PATCH] Add black level assertion. --- lensless/utils/image.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lensless/utils/image.py b/lensless/utils/image.py index edb213fc..6985592d 100644 --- a/lensless/utils/image.py +++ b/lensless/utils/image.py @@ -265,6 +265,9 @@ def bayer2rgb_cc( dtype = np.uint16 else: dtype = np.uint8 + assert ( + black_level < 2**nbits - 1 + ), f"Black level ({black_level}) too high for bit depth ({nbits})." # demosaic Bayer data img = cv2.cvtColor(img, cv2.COLOR_BayerRG2RGB)