Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,23 +52,23 @@ def classic_filter(image, filter_type):
|
|
| 52 |
edges = cv2.Canny(image, 100, 200)
|
| 53 |
return cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
|
| 54 |
|
| 55 |
-
def
|
| 56 |
"""Creative and unusual image filters"""
|
| 57 |
if filter_type == "Pixel Art":
|
| 58 |
h, w = image.shape[:2]
|
| 59 |
-
|
| 60 |
-
small = cv2.resize(image, (w//piksel_size, h//
|
| 61 |
return cv2.resize(small, (w, h), interpolation=cv2.INTER_NEAREST)
|
| 62 |
|
| 63 |
elif filter_type == "Mosaic Effect":
|
| 64 |
h, w = image.shape[:2]
|
| 65 |
-
|
| 66 |
-
for i in range(0, h,
|
| 67 |
-
for j in range(0, w,
|
| 68 |
-
roi = image[i:i+
|
| 69 |
if roi.size > 0:
|
| 70 |
color = np.mean(roi, axis=(0,1))
|
| 71 |
-
image[i:i+
|
| 72 |
return image
|
| 73 |
|
| 74 |
elif filter_type == "Rainbow":
|
|
|
|
| 52 |
edges = cv2.Canny(image, 100, 200)
|
| 53 |
return cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
|
| 54 |
|
| 55 |
+
def creative_filter(image, filter_type):
|
| 56 |
"""Creative and unusual image filters"""
|
| 57 |
if filter_type == "Pixel Art":
|
| 58 |
h, w = image.shape[:2]
|
| 59 |
+
pixsel_size = 20
|
| 60 |
+
small = cv2.resize(image, (w//piksel_size, h//pixsel_size))
|
| 61 |
return cv2.resize(small, (w, h), interpolation=cv2.INTER_NEAREST)
|
| 62 |
|
| 63 |
elif filter_type == "Mosaic Effect":
|
| 64 |
h, w = image.shape[:2]
|
| 65 |
+
mosaic_size = 30
|
| 66 |
+
for i in range(0, h, mosaic_size):
|
| 67 |
+
for j in range(0, w, mosaic_size):
|
| 68 |
+
roi = image[i:i+mosaic_size, j:j+mosaic_size]
|
| 69 |
if roi.size > 0:
|
| 70 |
color = np.mean(roi, axis=(0,1))
|
| 71 |
+
image[i:i+mosaic_size, j:j+mosaic_size] = color
|
| 72 |
return image
|
| 73 |
|
| 74 |
elif filter_type == "Rainbow":
|