File size: 570 Bytes
15d8d2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc6b824
5ea5833
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streamlit as st
import cv2
import numpy as np
from PIL import Image

st.title("Grayscale Image Converter")

uploaded_file = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])

if uploaded_file is not None:
    # Load image using PIL and convert to numpy array
    image = Image.open(uploaded_file)
    img_array = np.array(image)

    # Convert to grayscale using OpenCV
    gray_img = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)

    # Display grayscale image
    st.image(gray_img, caption="Grayscale Image", use_container_width=True, clamp=True)