From b069ab194219d40cab3841eff98820e33992cbcd Mon Sep 17 00:00:00 2001 From: webbrain-one <295484252+webbrain-one@users.noreply.github.com> Date: Tue, 4 Aug 2026 22:21:48 +0300 Subject: [PATCH] Fix: Handle grayscale images in open_image to avoid unpack error Patch generated by inclusionai/ling-3.0-flash:free via OpenRouter. --- haze_removal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/haze_removal.py b/haze_removal.py index bd0e5a8..5efcf60 100644 --- a/haze_removal.py +++ b/haze_removal.py @@ -12,8 +12,9 @@ def __init__(self, omega=0.95, t0=0.1, radius=7, r=20, eps=0.001): def open_image(self, img_path): img = Image.open(img_path) + if img.mode != 'RGB': + img = img.convert('RGB') self.src = np.array(img).astype(np.double)/255. - # self.gray = np.array(img.convert('L')) self.rows, self.cols, _ = self.src.shape self.dark = np.zeros((self.rows, self.cols), dtype=np.double) self.Alight = np.zeros((3), dtype=np.double)