From b65a41d2aeb5ae71078b5d4b2aba9ed3e4f36097 Mon Sep 17 00:00:00 2001 From: mdarnold1 <61575182+mdarnold1@users.noreply.github.com> Date: Tue, 11 Nov 2025 07:30:12 +1100 Subject: [PATCH] Update irpythermal.py dead_pixels_mask to also include hot pixels --- irpythermal.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/irpythermal.py b/irpythermal.py index 915e3f7..00bdc73 100755 --- a/irpythermal.py +++ b/irpythermal.py @@ -503,13 +503,11 @@ def calibrate_raw(self, quiet=False) -> None: threshold_margin = ( max_val - min_val ) * 0.05 # Adjust the margin if not detected correctly - threshold = min_val + threshold_margin - + threshold_lo = min_val + threshold_margin + threshold_hi = max_val - threshold_margin # if there are no dead pixels, we skip the dead pixel correction - if np.count_nonzero(frame_visible_float < threshold) != 0: - self.dead_pixels_mask = cv2.inRange( - frame_visible_float, 0, float(threshold) - ).astype(np.uint8) + if np.count_nonzero(frame_visible_float < threshold_lo) != 0 or np.count_nonzero(frame_visible_float > threshold_hi) != 0: + self.dead_pixels_mask = cv2.bitwise_not(cv2.inRange(frame_visible_float, float(threshold_lo), float(threshold_hi))).astype(np.uint8) if not quiet: print(f"Found {np.count_nonzero(self.dead_pixels_mask)} dead pixels")