python sitk.show()與imageJ結合使用常見的問題
在python中配置simpleITK時,遇到了以下這個問題。
simpleITK已經通過pip install安裝,但是sitk.show()功能無法正常使用,類似如下
實例代碼
import SimpleITK as sitk import sys import os example = sitk.ReadImage("filename") sitk.show(example)
在sitk.show()這一步會出現(xiàn)以下錯誤
“Traceback (most recent call last):
File "", line 1, in
sitk.Show(image)
File "C:\Python27\lib\site-packages\SimpleITK.py", line 4158, in Show
return _SimpleITK.Show(*args, **kwargs)
RuntimeError: Exception thrown in SimpleITK Show: ............\Build\ITK\SimpleITK-0.7.1\Code\IO\src\sitkShow.cxx:463:
sitk::ERROR: Error in administrating child process: [參數(shù)錯誤。]”
原因是SimpleITK的圖像顯示功能是通過類似ITK-snap,ImageJ進行實現(xiàn)的,所以在進行sitk.show()之前,需要對此進行設置才能正常實現(xiàn)。
這里參考stack overflow別人給的意見https://stackoverflow.com/questions/43215774/can-not-linksimpleitkshow-with-fiji
ImageJ Installation
Go to https://imagej.nih.gov/ij/download.html
Make sure to download the bundled with 64-bit Java 1.8.0_112 version
ImageJ Setup
Go to https://imagej.nih.gov/ij/plugins/nifti.html
Download nifti_io.jar
Go to C:\blah\blah\ImageJ\plugins\Input-Output
Delete the existing nifti_io.jar file from the folder
Copy the downloaded nifti_io.jar file into the folder
Restart ImageJ and check if File -> Import -> NIfTI-Analyze is there
If it is there, the plugin was successfully installed
SimpleITK Setup
Find the path where your ImageJ.exe file exists
Open cmd
Type in setx SITK_SHOW_COMMAND "C:\blah\blah\ImageJ\ImageJ.exe"
You should get the message SUCCESS: Specified value was saved
Check if everything works
Restart your text editor or IDE (if it was already open)
Run your code
除了下載ImageJ操作,另外的很簡單。
- 在環(huán)境變量里面添加SITK_SHOW_COMMAND ,以imageJ為例,路徑指向ImageJ-win64.exe
- 在環(huán)境變量中的path中添加%SITK_SHOW_COMMAND%
到此這篇關于python sitk.show()與imageJ結合使用常見的問題的文章就介紹到這了,更多相關sitk.show()結合imageJ內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- Python庫skimage繪制二值圖像代碼實例
- Python 實現(xiàn)Image和Ndarray互相轉換
- Python 實現(xiàn)將數(shù)組/矩陣轉換成Image類
- Python Pillow.Image 圖像保存和參數(shù)選擇方式
- Python 實現(xiàn)OpenCV格式和PIL.Image格式互轉
- 詳解python opencv、scikit-image和PIL圖像處理庫比較
- Python imageio讀取視頻并進行編解碼詳解
- Python圖像處理模塊ndimage用法實例分析
- 在python image 中安裝中文字體的實現(xiàn)方法
- 解決Python3用PIL的ImageFont輸出中文亂碼的問題
相關文章
TensorFlow2.4完成Word2vec詞嵌入訓練方法詳解
這篇文章主要為大家介紹了TensorFlow2.4完成Word2vec詞嵌入訓練方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11python?manage.py?createsuperuser運行錯誤問題解決
這篇文章主要介紹了python?manage.py?createsuperuser運行錯誤,本文給大家分享錯誤復現(xiàn)及解決方案,感興趣的朋友一起看看吧2023-10-10