NassimeBejaia commited on
Commit
0fd84ac
1 Parent(s): a59ff1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -163,8 +163,18 @@ def process_image(selected_image):
163
  # blurred_img = cv2.GaussianBlur(gray_image, (3, 3), 0)
164
 
165
  # Apply adaptive thresholding
 
 
 
 
 
 
 
 
 
 
166
 
167
- adaptive_threshold = filters.threshold_local(gray_image, block_size=35, offset=10)
168
 
169
  binary_adaptive = gray_image > adaptive_threshold
170
 
 
163
  # blurred_img = cv2.GaussianBlur(gray_image, (3, 3), 0)
164
 
165
  # Apply adaptive thresholding
166
+
167
+ # Let's assume `image` is your grayscale image array
168
+ height, width = gray_image.shape
169
+
170
+ # Example: setting block size to 1/30th of the average image dimension, making sure it's odd.
171
+ block_size = ((height + width) // 2) // 30
172
+ block_size = block_size + 1 if block_size % 2 == 0 else block_size
173
+
174
+ # Example: setting offset to a small fraction of the global mean intensity.
175
+ offset = np.mean(image) * 0.05
176
 
177
+ adaptive_threshold = filters.threshold_local(gray_image, block_size, offset)
178
 
179
  binary_adaptive = gray_image > adaptive_threshold
180