wg25r
commited on
Commit
·
8f8ddfc
1
Parent(s):
61977ba
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
st.title("Image Average Pixel Calculator")
|
6 |
+
uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
|
7 |
+
if uploaded_file:
|
8 |
+
image = Image.open(uploaded_file)
|
9 |
+
st.image(image, caption="Uploaded image", use_column_width=True)
|
10 |
+
image_np = np.array(image)
|
11 |
+
if image_np.ndim == 3:
|
12 |
+
avg_pixel = image_np.mean(axis=(0, 1))
|
13 |
+
else:
|
14 |
+
avg_pixel = image_np.mean()
|
15 |
+
st.write("Average pixel values:", avg_pixel
|