File size: 513 Bytes
7532d32 c5d8bd1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import streamlit as st
from PIL import Image
import numpy as np
st.title("Image Average Pixel Calculator")
uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
if uploaded_file:
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded image", use_column_width=True)
image_np = np.array(image)
if image_np.ndim == 3:
avg_pixel = image_np.mean(axis=(0, 1))
else:
avg_pixel = image_np.mean()
st.write("Average pixel values:", avg_pixel) |