KM_2024_Docker / visualize_x3d /dicom_toImg.py
datnguyentien204's picture
Upload 337 files
ce91ea1 verified
raw
history blame
351 Bytes
import streamlit as st
import pydicom
import cv2
import numpy as np
@st.cache_resource
def convert_dcm_to_png(input_image_path, output_image_path='a.png'):
ds = pydicom.dcmread(input_image_path)
img = ds.pixel_array
img = cv2.normalize(img, None, 0, 255, cv2.NORM_MINMAX).astype(np.uint8)
cv2.imwrite(output_image_path, img)