Spaces:
Runtime error
Runtime error
Create shadow_detection.py
Browse files
services/shadow_detection.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from PIL import Image
|
| 3 |
+
|
| 4 |
+
def detect_shadows(image):
|
| 5 |
+
grayscale = np.array(Image.fromarray(image).convert('L'))
|
| 6 |
+
shadow_area = grayscale < 50
|
| 7 |
+
shadow_locations = np.where(shadow_area)
|
| 8 |
+
return [{"type": "Shadow/Dust", "location": (x, y)} for x, y in zip(shadow_locations[1], shadow_locations[0])]
|