From 0b8bac1f1923833bea4ab5d1fc741134cd5cde23 Mon Sep 17 00:00:00 2001 From: Stuart Swerdloff Date: Sat, 21 Oct 2023 22:05:14 +1300 Subject: [PATCH] apply guard, check bin index is within range prior to indexing in to histogram --- src/View/mainpage/WindowingSlider.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/View/mainpage/WindowingSlider.py b/src/View/mainpage/WindowingSlider.py index 5bad4c03..c53205c9 100644 --- a/src/View/mainpage/WindowingSlider.py +++ b/src/View/mainpage/WindowingSlider.py @@ -208,7 +208,8 @@ def initialise_density_histogram(self): p = min(pixel, WindowingSlider.MAX_PIXEL_VALUE) p = max(p, 0) p = round(p) - self.densities[s][p] += 1 + if p>=0 and p < WindowingSlider.MAX_PIXEL_VALUE: + self.densities[s][p] += 1 max_value = max(self.densities[s]) min_value = min(self.densities[s]) avg_value = np.average(self.densities[s])