molehh commited on
Commit
3f4b254
·
1 Parent(s): ba188dd

first commit

Browse files
Files changed (2) hide show
  1. main.py +48 -0
  2. requirements.txt +4 -0
main.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ st.title("📸Image Processing App")
7
+
8
+ # Upload image
9
+ uploaded_file = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"])
10
+
11
+ if uploaded_file is not None:
12
+ image = Image.open(uploaded_file)
13
+
14
+ # Convert PIL image to OpenCV format
15
+ img_array = np.array(image)
16
+
17
+ # Show original image
18
+ st.subheader("Original vs Processed Image")
19
+ col1, col2 = st.columns(2)
20
+
21
+ with col1:
22
+ st.image(image, caption="Original Image", use_container_width=True)
23
+
24
+ processed_image = img_array # Initialize processed_image with original image
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
47
+ with col2:
48
+ st.image(processed_image, caption="Processed Image", use_container_width=True)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ cv2
3
+ numpy
4
+ PIL