Ubuntu中python调用SimpleITK来显示图像

前端之家收集整理的这篇文章主要介绍了Ubuntu中python调用SimpleITK来显示图像前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转自:http://blog.csdn.net/jiandanjinxin/article/details/53232440

misc.imshow

ipython
import os
from scipy import misc
dataDir = os.environ["HOME"] + "/Downloads/SimpleITK-MICCAI-2001-Tutorial-master/Data"
print dataDir
image = misc.imread(dataDir + "FA.png")
misc.imshow(image)

或者
ipython
import os
from scipy import misc
fileName ='/home/bids/Downloads/SimpleITK-MICCAI-2001-Tutorial-master/Data/FA.png'
print dataDir
image = misc.imread(fileName)
misc.imshow(image)

sitk.Show
ipython
import SimpleITK as sitk
fileName ='/home/bids/Downloads/SimpleITK-MICCAI-2001-Tutorial-master/Data/FA.png'
img = sitk.ReadImage(fileName)
scalarImage = sitk.Cast(img,sitk.sitkUInt32)
sitk.Show(scalarImage)

或者
ipython
import SimpleITK as sitk
import os
dataDir = os.environ["HOME"] + "/Downloads/SimpleITK-MICCAI-2001-Tutorial-master/Data"
print dataDir
image = sitk.ReadImage(dataDir + "/FA.png")
sitk.Show(image)

备注:
采用sitk.Show 是 默认打开imagej去打开图像,往往有时候仅仅是打开了imagej,而无法显示图像。

References

http://stackoverflow.com/questions/34726455/setting-the-image-viewer-in-python



这部分内容未测试,具体情况不明:

import itk
pixelType = itk.UC
imageType = itk.Image[pixelType,2]
readerType = itk.ImageFileReader[imageType]
writerType = itk.ImageFileWriter[imageType]
reader = readerType.New()
writer = writerType.New()
reader.SetFileName("<input image file location>")
writer.SetFileName("D:/Output.png")
writer.SetInput( reader.GetOutput() )
writer.Update()
原文链接:https://www.f2er.com/ubuntu/354338.html

猜你在找的Ubuntu相关文章