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()这一步会出现以下错误

“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: [参数错误。]”

原因是SimpleITK的图像显示功能是通过类似ITK-snap,ImageJ进行实现的,所以在进行sitk.show()之前,需要对此进行设置才能正常实现。

这里参考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操作,另外的很简单。

  • 在环境变量里面添加SITK_SHOW_COMMAND ,以imageJ为例,路径指向ImageJ-win64.exe
  • 在环境变量中的path中添加%SITK_SHOW_COMMAND%

到此这篇关于python sitk.show()与imageJ结合使用常见的问题的文章就介绍到这了,更多相关sitk.show()结合imageJ内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • 详解python opencv、scikit-image和PIL图像处理库比较

    进行深度学习时,对图像进行预处理的过程是非常重要的,使用pytorch或者TensorFlow时需要对图像进行预处理以及展示来观看处理效果,因此对python中的图像处理框架进行图像的读取和基本变换的掌握是必要的,接下来python中几个基本的图像处理库进行纵向对比. 项目地址:https://github.com/Oldpan/Pytorch-Learn/tree/master/Image-Processing 比较的图像处理框架: PIL scikit-image opencv-python

  • Python 实现OpenCV格式和PIL.Image格式互转

    OpenCV转换成PIL.Image格式: import cv2 from PIL import Image import numpy img = cv2.imread("plane.jpg") cv2.imshow("OpenCV",img) image = Image.fromarray(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) image.show() cv2.waitKey() PIL.Image转换成OpenCV格式: im

  • Python 实现Image和Ndarray互相转换

    如下所示: import numpy as np from PIL import Image img = Image.open(filepath) img_convert_ndarray = np.array(img) ndarray_convert_img= Image.fromarray(img_convert_ndarray ) # np.array(object) 这个函数很强大啊,看源码里面给的注释 # object : array_like # An array, any objec

  • Python库skimage绘制二值图像代码实例

    二值图像的凸壳指的是包围输入二值图像白色区域的最小的凸多边形的像素集合. skimage中的函数 from skimage.morphology import convex_hull_image chull = convex_hull_image(image) 完整代码: """ =========== Convex Hull =========== The convex hull of a binary image is the set of pixels included

  • 解决Python3用PIL的ImageFont输出中文乱码的问题

    今天在用python3+ImageFont输出中文时,结果显示乱码 # coding:utf-8 from PIL import Image, ImageDraw, ImageFont image= Image.new('RGB', (559, 320),(255,255,255)) draw = ImageDraw.Draw(image) # draw.text() font = ImageFont.truetype("arial", 40, encoding="unic&

  • 在python image 中安装中文字体的实现方法

    如果一些应用需要到中文字体(如果pygraphviz,不安装中文字体,中文会显示乱码),就要在image 中安装中文字体. 默认 python image 是不包含中文字体的: mac-temp:relation_graph test$ docker run --rm -it python bash root@36d738e2084c:/# fc-list /usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:st

  • Python 实现将数组/矩阵转换成Image类

    先说明一下为什么要将数组转换成Image类.我处理的图像是FITS (Flexible Image Transport System)文件,是一种灰度图像文件,也就是单通道图像. FITS图像的特点是灰度值取值为0~65535,这类图像在python下读成数组首先是不能直接转换成位图,也就不能用OpenCV.Image等方法了. 如果是普通的jpg图像,用自带的Image库就能实现很多功能. 下方的这幅图就是通过python下的Image库中的rotate函数实现的 接下来贴上代码. impor

  • Python图像处理模块ndimage用法实例分析

    本文实例讲述了Python图像处理模块ndimage用法.分享给大家供大家参考,具体如下: 一 原始图像 1 代码 from scipy import misc from scipy import ndimage import matplotlib.pyplot as plt face = misc.face()#face是测试图像之一 plt.figure()#创建图形 plt.imshow(face)#绘制测试图像 plt.show()#原始图像 2 运行结果 二 高斯滤波 1 代码 fro

  • Python Pillow.Image 图像保存和参数选择方式

    保存时代码如下: figure_corp = figure.crop( (32*rate/2, 32*rate/2, 32-32*rate/2, 32-32*rate/2)) figure.save('save_picture/picture.jpg',quality=95,subsampling=0) figure_corp.save('save_picture/picture_crop.jpg',quality=95,subsampling=0) 其中quality数值会影响图片的质量(1最

  • Python imageio读取视频并进行编解码详解

    读视频和写视频一直由于编解码的问题给程序员造成很多麻烦.对此进行了一些探索.用Python读取视频有两种主要方法,分别是基于imageio库和OpenCV,其中OpenCV加上ffmpeg的安装编译很麻烦,推荐大家使用第一种方法,不过大家也可依据自己的需求进行使用. 方法一:使用imageio库 1. 一般imageio库Anconda自带的有,不用我们单独安装,没有安装的可用pip安装或自己下载. imageio使用方法可参考:http://imageio.readthedocs.io/en/

随机推荐