From 287b4c6cc3b8b76053f1a56c691da15a0198a4d5 Mon Sep 17 00:00:00 2001 From: Nathan van Beelen Date: Fri, 11 Mar 2022 17:57:32 +0100 Subject: [PATCH 1/2] Use the OpenCV function instead of clipping --- stytra/tracking/preprocessing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stytra/tracking/preprocessing.py b/stytra/tracking/preprocessing.py index b78219b5..96b8a289 100644 --- a/stytra/tracking/preprocessing.py +++ b/stytra/tracking/preprocessing.py @@ -43,7 +43,9 @@ def _process( if color_invert: im = 255 - im if clip > 0: - im = np.maximum(im, clip) - clip + # Maxval only exists because it is required, + # since we use cv2.THRES_TOZERO, we do not set things to maxval. + im = cv2.threshold(src=im, thresh=clip, maxval=255, type=cv2.THRESH_TOZERO)[1] if self.set_diagnostic == "filtered": self.diagnostic_image = im From 1b178f9a1fa48c1ab66457cfeb0a6096ee13bc82 Mon Sep 17 00:00:00 2001 From: Nathan van Beelen Date: Fri, 25 Mar 2022 16:11:43 +0100 Subject: [PATCH 2/2] Change formatting according to black --- stytra/tracking/preprocessing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stytra/tracking/preprocessing.py b/stytra/tracking/preprocessing.py index 96b8a289..283b3ee5 100644 --- a/stytra/tracking/preprocessing.py +++ b/stytra/tracking/preprocessing.py @@ -45,7 +45,9 @@ def _process( if clip > 0: # Maxval only exists because it is required, # since we use cv2.THRES_TOZERO, we do not set things to maxval. - im = cv2.threshold(src=im, thresh=clip, maxval=255, type=cv2.THRESH_TOZERO)[1] + im = cv2.threshold(src=im, thresh=clip, maxval=255, type=cv2.THRESH_TOZERO)[ + 1 + ] if self.set_diagnostic == "filtered": self.diagnostic_image = im