fffiloni commited on
Commit
9f95f84
1 Parent(s): 97f0d9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -3,12 +3,27 @@ import cv2
3
  import numpy as np
4
 
5
  def preprocess(img):
 
6
  img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
 
 
 
7
  img_blur = cv2.GaussianBlur(img_gray, (5, 5), 1)
8
- img_canny = cv2.Canny(img, 50, 50)
 
 
 
 
 
 
9
  kernel = np.ones((3, 3))
10
  img_dilate = cv2.dilate(img_canny, kernel, iterations=2)
 
 
 
11
  img_erode = cv2.erode(img_dilate, kernel, iterations=1)
 
 
12
  return img_erode
13
 
14
  def find_tip(points, convex_hull):
 
3
  import numpy as np
4
 
5
  def preprocess(img):
6
+ # Convert to grayscale
7
  img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
8
+ cv2.imwrite("1_gray.png", img_gray)
9
+
10
+ # Blur the image
11
  img_blur = cv2.GaussianBlur(img_gray, (5, 5), 1)
12
+ cv2.imwrite("2_blur.png", img_blur)
13
+
14
+ # Detect edges with Canny
15
+ img_canny = cv2.Canny(img_blur, 50, 50)
16
+ cv2.imwrite("3_canny.png", img_canny)
17
+
18
+ # Dilate the edges
19
  kernel = np.ones((3, 3))
20
  img_dilate = cv2.dilate(img_canny, kernel, iterations=2)
21
+ cv2.imwrite("4_dilate.png", img_dilate)
22
+
23
+ # Erode the dilated edges
24
  img_erode = cv2.erode(img_dilate, kernel, iterations=1)
25
+ cv2.imwrite("5_erode.png", img_erode)
26
+
27
  return img_erode
28
 
29
  def find_tip(points, convex_hull):