From 41f03958c6bb38093f3c1bab7ea583af40f86b9e Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Thu, 15 Feb 2024 17:34:29 +0000 Subject: [PATCH] Save images with saturated pixels If any pixels in the manually processed raw image end up saturated (>255), this causes an error. I've now manually clamped the values between 0 and 255 to fix this. It would probably be a good idea to warn when this happens, as it does mean we're losing data. --- src/openflexure_microscope_server/things/smart_scan.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 3c9d3be6..bd61e7ff 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -562,6 +562,8 @@ class SmartScanThing(Thing): def process_raw_image(img): normed = img/white_norm corrected = np.dot(colour_correction_matrix, normed.reshape((-1, 3)).T).T.reshape(normed.shape) + corrected[corrected < 0] = 0 + corrected[corrected > 255] = 255 return gamma_8bit(corrected) logger.info( f"Generated normalisation image with shape {white_norm.shape}, "