我有以下代碼。print(image.GetDimension())作業并列印輸出(512, 512, 17)。但sitk.Show(image)不起作用。
我的代碼
import SimpleITK as sitk
path = "C:/Users/myUserName/Desktop/0001.DCM"
image = sitk.ReadImage(path)
print(image.GetDimension())
sitk.Show(image)
我的錯誤資訊是:
RuntimeError: Exception thrown in SimpleITK Show: D:\a\1\sitk\Code\IO\src\sitkImageViewer.cxx:562:
sitk::ERROR: Error in administrating child process: [Access is denied].
Command line: 'C:\Users\myUserName\Fiji.app' 'C:\\Users\\myUserName\\AppData\\Local\\Temp\\TempFile-21536-2.mha'
我該如何解決?我已經解壓 ImageJ 并將Fiji.app檔案夾放在C:\Users\myUserName\Fiji.app. DICOM 影像0001.DCM沒有問題,因為我可以通過一些在線 DICOM 查看器查看它。我使用的是 Windows 10,并在 Spyder 中運行我的 Python 代碼。提前致謝!
uj5u.com熱心網友回復:
嘗試將 SITK_SHOW_COMMAND 設定為直接指向 ImageJ 可執行檔案。對于您的斐濟安裝,環境變數應設定為 C:\Users\myUserName\Fiji.app\ImageJ-win64.exe。
好的,這是我稍微修改過的腳本版本:
import SimpleITK as sitk
#path = "C:/Users/myUserName/Desktop/0001.DCM"
path = "C:\SimpleITK-build\SimpleITK-build\ExternalData\Testing\Data\Input\DicomSeries\Image0075.dcm"
image = sitk.ReadImage(path)
print(image.GetDimension())
sitk.Show(image, debugOn=True)
唯一的區別是我在對 Show 的呼叫中添加了 debugOn 標志。
這是我的輸出:
Debug: In D:\bld\libsimpleitk_1627514864077\work\Code\IO\src\sitkImageViewer.cxx, line 495: ExecuteCommand: 'C:/Users/dchen/Fiji.app/ImageJ-win64.exe' '-eval' 'open("C:\\Users\\dchen\\AppData\\Local\\Temp\\TempFile-10808-0.mha"); rename("C:\\Users\\dchen\\AppData\\Local\\Temp\\TempFile-10808-0.mha");'
Debug: In D:\bld\libsimpleitk_1627514864077\work\Code\IO\src\sitkImageViewer.cxx, line 576: Done. Deleting process.
您可以準確地看到 SimpleITK 正在執行以呼叫斐濟的命令。特別是,正在啟動的程式是“C:/Users/dchen/Fiji.app/ImageJ-win64.exe”。
如果打開 debugOn 標志,SimpleITK 輸出什么?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/334677.html
