From 2a0e1decfa24a3d87d0175770405856cdd0d5d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=AA=20Trung=20Hi=E1=BA=BFu?= Date: Mon, 25 Nov 2024 20:49:09 +0700 Subject: [PATCH] Fix issue with value euqal to 0 --- WAS_Node_Suite.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WAS_Node_Suite.py b/WAS_Node_Suite.py index cbe60a9..080fccd 100644 --- a/WAS_Node_Suite.py +++ b/WAS_Node_Suite.py @@ -6227,7 +6227,10 @@ class WAS_Image_Levels: im_arr = np.clip(im_arr, 0, 255) # mid-level adjustment - gamma = math.log(0.5) / math.log((self.mid_level - self.min_level) / (self.max_level - self.min_level)) + if self.mid_level <= self.min_level: + gamma = 1.0 + else: + gamma = math.log(0.5) / math.log((self.mid_level - self.min_level) / (self.max_level - self.min_level)) im_arr = np.power(im_arr / 255, gamma) * 255 im_arr = im_arr.astype(np.uint8)