mallelapreethi commited on
Commit
b64a51d
·
verified ·
1 Parent(s): 70f6abe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -8
app.py CHANGED
@@ -5,20 +5,14 @@ from PIL import Image
5
  import io
6
 
7
  # Function to convert image to sketch with adjustable outline thickness
8
- def image_to_sketch(image, kernel_size=1):
9
  gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
10
  inverted_image = 255 - gray_image
11
  blurred_image = cv2.GaussianBlur(inverted_image, (21, 21), 0)
12
  inverted_blurred = 255 - blurred_image
13
  sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
14
 
15
- # Apply adaptive thresholding to enhance edges
16
- adaptive_thresh = cv2.adaptiveThreshold(sketch, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 2)
17
-
18
- # Apply morphological operation to thicken the outlines
19
- kernel = np.ones((kernel_size, kernel_size), np.uint8)
20
- sketch = cv2.dilate(adaptive_thresh, kernel, iterations=1)
21
-
22
  return sketch
23
 
24
  # Streamlit app layout
 
5
  import io
6
 
7
  # Function to convert image to sketch with adjustable outline thickness
8
+ def image_to_sketch(image):
9
  gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
10
  inverted_image = 255 - gray_image
11
  blurred_image = cv2.GaussianBlur(inverted_image, (21, 21), 0)
12
  inverted_blurred = 255 - blurred_image
13
  sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
14
 
15
+
 
 
 
 
 
 
16
  return sketch
17
 
18
  # Streamlit app layout