Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
18 |
|
19 |
return sketch
|
20 |
|
@@ -66,7 +69,7 @@ st.markdown("""
|
|
66 |
# Example conversions
|
67 |
st.subheader("Example Conversions")
|
68 |
|
69 |
-
#
|
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 |
|