DSatishchandra commited on
Commit
40cf333
·
verified ·
1 Parent(s): a06b7df

Create shadow_detection.py

Browse files
Files changed (1) hide show
  1. services/shadow_detection.py +8 -0
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])]