tharu22 commited on
Commit
6abb5d9
·
1 Parent(s): 6096434
Files changed (2) hide show
  1. app.py +46 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
+ import numpy as np
4
+ from PIL import Image, ImageEnhance
5
+
6
+ st.title("Image Processing ")
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
+ st.image(image, caption="Original Image", use_container_width=True)
14
+
15
+ # Convert PIL image to OpenCV format
16
+ img_array = np.array(image)
17
+
18
+ # Convert to Grayscale
19
+ if st.button("Convert to Grayscale"):
20
+ gray_image = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
21
+ st.image(gray_image, caption="Grayscale Image", use_container_width=True, channels="GRAY")
22
+
23
+ # Rotate Image
24
+ angle = st.slider("Select Rotation Angle", -180, 180, 0)
25
+ if st.button("Rotate Image"):
26
+ (h, w) = img_array.shape[:2]
27
+ center = (w // 2, h // 2)
28
+ matrix = cv2.getRotationMatrix2D(center, angle, 1.0)
29
+ rotated_image = cv2.warpAffine(img_array, matrix, (w, h))
30
+ st.image(rotated_image, caption=f"Rotated by {angle}°", use_container_width=True)
31
+
32
+
33
+
34
+ # Adjust Brightness
35
+ brightness = st.slider("Adjust Brightness", 0.1, 3.0, 1.0)
36
+ if st.button("Apply Brightness"):
37
+ enhancer = ImageEnhance.Brightness(image)
38
+ bright_image = enhancer.enhance(brightness)
39
+ st.image(bright_image, caption="Brightness Adjusted", use_container_width=True)
40
+
41
+ # Adjust Sharpness
42
+ sharpness = st.slider("Adjust Sharpness", 0.1, 3.0, 1.0)
43
+ if st.button("Apply Sharpness"):
44
+ enhancer = ImageEnhance.Sharpness(image)
45
+ sharp_image = enhancer.enhance(sharpness)
46
+ st.image(sharp_image, caption="Sharpness Adjusted", use_container_width=True)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit>=1.0.0
2
+ opencv-python>=4.5.0
3
+ numpy>=1.19.0
4
+ Pillow>=8.0.0