DSatishchandra's picture
Update services/shadow_detection.py
2e1fcfe verified
raw
history blame contribute delete
581 Bytes
import numpy as np # Import NumPy for array operations
from PIL import Image # Import PIL for image conversion
# Function to detect shadows or dust (optional, for preprocessing)
def detect_shadows(image):
grayscale = np.array(Image.fromarray(image).convert('L')) # Convert to grayscale
shadow_area = grayscale < 50 # Threshold for shadow/dust detection
shadow_locations = np.where(shadow_area) # Get coordinates of shadows
return [{"type": "Shadow/Dust", "location": (x, y)} for x, y in zip(shadow_locations[1], shadow_locations[0])] # Return list of shadows