Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,20 +5,18 @@ import numpy as np
|
|
5 |
|
6 |
|
7 |
def inference(img):
|
8 |
-
|
9 |
-
|
10 |
# https://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.remove_small_objects
|
11 |
# my_result = cv2.remove_small_objects(binarized.astype(bool), min_size=2, connectivity=2).astype(int)
|
12 |
|
13 |
-
img_bw = 255*(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) > 5).astype('uint8')
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
mask = cv2.morphologyEx(
|
18 |
-
mask =
|
19 |
-
|
20 |
-
mask = np.dstack([mask, mask, mask]) / 255
|
21 |
-
out = img * mask
|
22 |
|
23 |
return out
|
24 |
|
|
|
5 |
|
6 |
|
7 |
def inference(img):
|
8 |
+
out = cv2.erode(img,(1,1))
|
9 |
+
out = cv2.dilate(my_result,(1,1))
|
10 |
# https://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.remove_small_objects
|
11 |
# my_result = cv2.remove_small_objects(binarized.astype(bool), min_size=2, connectivity=2).astype(int)
|
12 |
|
13 |
+
#img_bw = 255*(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) > 5).astype('uint8')
|
14 |
+
#se1 = cv2.getStructuringElement(cv2.MORPH_RECT, (5,5))
|
15 |
+
#se2 = cv2.getStructuringElement(cv2.MORPH_RECT, (2,2))
|
16 |
+
#mask = cv2.morphologyEx(img_bw, cv2.MORPH_CLOSE, se1)
|
17 |
+
#mask = cv2.morphologyEx(mask, cv2.MORPH_OPEN, se2)
|
18 |
+
#mask = np.dstack([mask, mask, mask]) / 255
|
19 |
+
#out = img * mask
|
|
|
|
|
20 |
|
21 |
return out
|
22 |
|