我有一个python文件(abc.py
),在那里我读取一个特定的dicom图像(abc.dcm
),我的输出是dicom图像数据,比如与dicom图像相关的名称、ID、年龄等。。。。你知道吗
我有另一个python文件(text.py
),其中iam使用flask呈现html页面(文本.html).... 你知道吗
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/text')
def text():
return render_template('text.html')
if __name__ == "__main__":
app.run(debug=True)
现在我需要上传相同的dicom图像在html中,这样它应该返回我的python文件的输出(abc.py
…我在html页面中使用dicom图像)。。。。你知道吗
我在这里使用flask呈现html页面
在文本.py地址:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/text')
def text():
return render_template('text.html')
if __name__ == "__main__":
app.run(debug=True)
在abc.py公司地址:
import pydicom as dicom
import matplotlib.pyplot as plt
print(__doc__)
fileName ='005-GE_PART-VIEW5.dcm'
dataset = dicom.dcmread(fileName) #reading the given dicom file
#print(dataset)
pixeldata = dataset.pixel_array #to convert pixeldata to numpy array
#print(pixeldata)
#print(pixeldata.shape) #to get the array size
print()
print("Filename.........:", fileName)
print("Storage type.....:", dataset.SOPClassUID)
print()
#Displaying patient information
pat_name = dataset.PatientName
display_name = pat_name.family_name + ", " + pat_name.given_name
print("Patient's name...:", display_name)
print("Patient id.......:", dataset.PatientID)
print("Modality.........:", dataset.Modality)
print("Study Date.......:", dataset.StudyDate)
if 'PixelData' in dataset:
rows = int(dataset.Rows)
cols = int(dataset.Columns)
print("Image size.......: {rows:d} x {cols:d}, {size:d} bytes".format(
rows=rows, cols=cols, size=len(dataset.PixelData)))
if 'PixelSpacing' in dataset:
print("Pixel spacing....:", dataset.PixelSpacing)
# use .get() if not sure the item exists, and want a default value if missing
print("Slice location...:", dataset.get('SliceLocation', "(missing)"))
# plot the image using matplotlib
plt.imshow(dataset.pixel_array, cmap=plt.cm.bone)
plt.show()
#function to give tag information by passing GroupID and ElementID
def fun(GroupID,ElementID):
return dataset[GroupID,ElementID].value;
a = fun(0x0010,0x0010)
print(a)
我希望它上传和返回的html页面
目前没有回答
相关问题 更多 >
编程相关推荐