Spaces:
Build error
Build error
| import cv2 | |
| import numpy as np | |
| def preprocess_image(image: np.ndarray) -> np.ndarray: | |
| # Simple preprocessing: enhance contrast | |
| lab = cv2.cvtColor(image, cv2.COLOR_BGR2LAB) | |
| clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) | |
| lab[:, :, 0] = clahe.apply(lab[:, :, 0]) | |
| return cv2.cvtColor(lab, cv2.COLOR_LAB2BGR) | |
| def extract_features(image: np.ndarray, mask: np.ndarray) -> dict: | |
| # Extract color histogram | |
| color_histogram = cv2.calcHist([image], [0, 1, 2], mask, [8, 8, 8], [0, 256, 0, 256, 0, 256]) | |
| color_histogram = cv2.normalize(color_histogram, color_histogram).flatten() | |
| return {'color': color_histogram} |