這裏是我想在Python實現(請記住,我是比較新的蟒蛇):變換DICOM圖像到XYZ座標和它們的值的列表 - Python的
- 一個轉換DICOM圖像轉換爲xyz座標列表及其各自的像素值並將列表導出到.csv文件。
- 從上一個任務中生成的xyz座標和像素值列表中重新生成相同的圖像。
到目前爲止,我已經能夠讀取dicom圖像並通過使用pydicom和numpy將它們轉換爲數組。我還能夠通過幾個for循環提取像素和座標值,並將該列表導出爲.csv。但是,爲了保持某種質量控制,必須有更好的方法來保持這種質量控制,因爲當我嘗試重新生成圖像時(通過使用另一組for循環),我無法獲得原始圖像。
我需要兩個函數分別在不同的python腳本中運行。
這是我到目前爲止有:
#Raster through all pixels and copy each value and coordinates to arrays
rc_cntr = 0
for r in range(0,img_rows):
for c in range(0,img_cols):
pixel = dcmarray[r, c]
rArray[rc_cntr] = r
cArray[rc_cntr] = c
zArray[rc_cntr] = z_cntr
imgArray[rc_cntr] = dcmarray[r,c]
rc_cntr = rc_cntr + 1;
#Combine arrays into one file
XYZV = numpy.column_stack([rArray,cArray,zArray, imgArray])
numpy.savetxt(output_path,XYZV,'%0i','\t') #Save XYZV files for each image
在這個問題上的任何幫助,將不勝感激。
乾杯 AFH
如果發佈一些你的代碼,你會增加你的機會得到一個有用的答案。 –