DSatishchandra commited on
Commit
2e1fcfe
·
verified ·
1 Parent(s): b6e0c17

Update services/shadow_detection.py

Browse files
Files changed (1) hide show
  1. services/shadow_detection.py +7 -6
services/shadow_detection.py CHANGED
@@ -1,8 +1,9 @@
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])]
 
1
+ import numpy as np # Import NumPy for array operations
2
+ from PIL import Image # Import PIL for image conversion
3
 
4
+ # Function to detect shadows or dust (optional, for preprocessing)
5
  def detect_shadows(image):
6
+ grayscale = np.array(Image.fromarray(image).convert('L')) # Convert to grayscale
7
+ shadow_area = grayscale < 50 # Threshold for shadow/dust detection
8
+ shadow_locations = np.where(shadow_area) # Get coordinates of shadows
9
+ return [{"type": "Shadow/Dust", "location": (x, y)} for x, y in zip(shadow_locations[1], shadow_locations[0])] # Return list of shadows