Spaces:
Runtime error
Runtime error
| import cv2 | |
| import numpy as np | |
| def preprocess_image(image: np.ndarray) -> np.ndarray: | |
| # Convert to LAB color space and apply CLAHE | |
| lab = cv2.cvtColor(image, cv2.COLOR_BGR2LAB) | |
| clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8)) | |
| lab[:, :, 0] = clahe.apply(lab[:, :, 0]) | |
| enhanced = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR) | |
| # Apply bilateral filtering | |
| denoised = cv2.bilateralFilter(enhanced, 9, 75, 75) | |
| return denoised |