-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
33 lines (26 loc) · 1.03 KB
/
streamlit_app.py
File metadata and controls
33 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
import plantcv.plantcv as pcv
import cv2
import numpy as np
# Don't know if this is necessary, but just in case
pcv.params.debug = None
st.title("Image Color Correction with PlantCV")
# File uploader
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
# Add tabs
tab1, tab2 = st.tabs(["Original", "Color Corrected"])
# Read in array once a file has been uploaded
if uploaded_file:
file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
# flip channels
image_flipped = cv2.merge((image[:, :, [2]],
image[:, :, [1]],
image[:, :, [0]]))
# Do the color correction and show both in tabs
cc = pcv.transform.auto_correct_color(image)
cc_flipped = cv2.merge((cc[:, :, [2]],
cc[:, :, [1]],
cc[:, :, [0]]))
tab1.image(image_flipped, use_column_width=True)
tab2.image(cc_flipped, use_column_width=True)