Spaces:
Sleeping
Sleeping
File size: 714 Bytes
3318510 e9f7fd2 3318510 e9f7fd2 |
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 |
import streamlit as st
import pydicom
import matplotlib.pyplot as plt
# Streamlit app title
st.title("DICOM Image Viewer")
# Upload a DICOM file
uploaded_file = st.file_uploader("Upload a DICOM file", type=["dcm"])
if uploaded_file is not None:
try:
# Read the uploaded DICOM file
dicom_data = pydicom.dcmread(uploaded_file)
# Display the DICOM image
plt.imshow(dicom_data.pixel_array, cmap=plt.cm.bone)
plt.axis("off")
plt.title("DICOM Image")
plt.tight_layout()
# Show the image in the Streamlit app
st.pyplot(plt)
except Exception as e:
st.error(f"Error: {str(e)}")
st.write("Upload a DICOM file to view the image.")
|