Spaces:
Sleeping
Sleeping
first commit
Browse files
main.py
CHANGED
|
@@ -25,22 +25,22 @@ if uploaded_file is not None:
|
|
| 25 |
|
| 26 |
# Convert to Grayscale
|
| 27 |
if st.button("Convert to Grayscale"):
|
| 28 |
-
processed_image =
|
| 29 |
|
| 30 |
# Rotate Image
|
| 31 |
angle = st.slider("Select Rotation Angle", -180, 180, 0)
|
| 32 |
if st.button("Rotate Image"):
|
| 33 |
(h, w) = img_array.shape[:2]
|
| 34 |
center = (w // 2, h // 2)
|
| 35 |
-
matrix =
|
| 36 |
-
processed_image =
|
| 37 |
|
| 38 |
# Add Text Overlay
|
| 39 |
text = st.text_input("Enter text to overlay on the image", "Hello")
|
| 40 |
if st.button("Apply Text Overlay"):
|
| 41 |
image_copy = img_array.copy()
|
| 42 |
-
font =
|
| 43 |
-
|
| 44 |
processed_image = image_copy
|
| 45 |
|
| 46 |
# Show processed image in the second column
|
|
|
|
| 25 |
|
| 26 |
# Convert to Grayscale
|
| 27 |
if st.button("Convert to Grayscale"):
|
| 28 |
+
processed_image = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
|
| 29 |
|
| 30 |
# Rotate Image
|
| 31 |
angle = st.slider("Select Rotation Angle", -180, 180, 0)
|
| 32 |
if st.button("Rotate Image"):
|
| 33 |
(h, w) = img_array.shape[:2]
|
| 34 |
center = (w // 2, h // 2)
|
| 35 |
+
matrix = cv2.getRotationMatrix2D(center, angle, 1.0)
|
| 36 |
+
processed_image = cv2.warpAffine(img_array, matrix, (w, h))
|
| 37 |
|
| 38 |
# Add Text Overlay
|
| 39 |
text = st.text_input("Enter text to overlay on the image", "Hello")
|
| 40 |
if st.button("Apply Text Overlay"):
|
| 41 |
image_copy = img_array.copy()
|
| 42 |
+
font = cv2.FONT_HERSHEY_SIMPLEX
|
| 43 |
+
cv2.putText(image_copy, text, (50, 50), font, 1, (255, 0, 0), 2, cv2.LINE_AA)
|
| 44 |
processed_image = image_copy
|
| 45 |
|
| 46 |
# Show processed image in the second column
|