mallelapreethi commited on
Commit
a8ce254
·
verified ·
1 Parent(s): 4cd134c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -12,9 +12,12 @@ def image_to_sketch(image, kernel_size=3):
12
  inverted_blurred = 255 - blurred_image
13
  sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
14
 
 
 
 
15
  # Apply morphological operation to thicken the outlines
16
  kernel = np.ones((kernel_size, kernel_size), np.uint8)
17
- sketch = cv2.dilate(sketch, kernel, iterations=1)
18
 
19
  return sketch
20
 
@@ -66,7 +69,7 @@ st.markdown("""
66
  # Example conversions
67
  st.subheader("Example Conversions")
68
 
69
- # Replace 'Dog.jpg' with the path to an example image if running locally
70
  example_image_path = 'Dog.jpg'
71
  example_image = cv2.imread(example_image_path)
72
 
 
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
 
 
69
  # Example conversions
70
  st.subheader("Example Conversions")
71
 
72
+ # Load and display example image
73
  example_image_path = 'Dog.jpg'
74
  example_image = cv2.imread(example_image_path)
75