sitk::ERROR: No ImageJ/Fiji application found.

Posted Data+Science+Insight

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sitk::ERROR: No ImageJ/Fiji application found.相关的知识,希望对你有一定的参考价值。

sitk::ERROR: No ImageJ/Fiji application found.

目录

sitk::ERROR: No ImageJ/Fiji application found.

问题:

解决:

完整错误:


问题:

执行simpleITK框架进行图像配准时候发生如下错误:

sitk::ERROR: No ImageJ/Fiji application found.

执行命令如下,可以使用不同的变换器。

python dalign.py 1703801.jpg 1703801_1.jpg composite.tfm
python dalign.py 1703801.jpg 1703801_1.jpg euler2D.tfm
python dalign.py 1703801.jpg 1703801_1.jpg RIRE_training_001_CT_2_mr_T1.tfm
python dalign.py 1703801.jpg 1703801_1.jpg composescaleskewversor.tfm
python dalign.py 1703801.jpg 1703801_1.jpg affine.tfm

import SimpleITK as sitk
import sys
import os


def command_iteration(filter):
    print(f"filter.GetElapsedIterations():3 = filter.GetMetric():10.5f")


if len(sys.argv) < 4:
    print(
        f"Usage: sys.argv[0]"
        + " <fixedImageFilter> <movingImageFile> <outputTransformFile>"
    )
    sys.exit(1)

fixed = sitk.ReadImage(sys.argv[1], sitk.sitkFloat32)

moving = sitk.ReadImage(sys.argv[2], sitk.sitkFloat32)

matcher = sitk.HistogramMatchingImageFilter()
matcher.SetNumberOfHistogramLevels(1024)
matcher.SetNumberOfMatchPoints(7)
matcher.ThresholdAtMeanIntensityOn()
moving = matcher.Execute(moving, fixed)

# The basic Demons Registration Filter
# Note there is a whole family of Demons Registration algorithms included in
# SimpleITK
demons = sitk.DemonsRegistrationFilter()
demons.SetNumberOfIterations(50)
# Standard deviation for Gaussian smoothing of displacement field
demons.SetStandardDeviations(1.0)

demons.AddCommand(sitk.sitkIterationEvent, lambda: command_iteration(demons))

displacementField = demons.Execute(fixed, moving)

print("-------")
print(f"Number Of Iterations: demons.GetElapsedIterations()")
print(f" RMS: demons.GetRMSChange()")

outTx = sitk.DisplacementFieldTransform(displacementField)

sitk.WriteTransform(outTx, sys.argv[3])

if "SITK_NOSHOW" not in os.environ:
    resampler = sitk.ResampleImageFilter()
    resampler.SetReferenceImage(fixed)
    resampler.SetInterpolator(sitk.sitkLinear)
    resampler.SetDefaultPixelValue(100)
    resampler.SetTransform(outTx)

    out = resampler.Execute(moving)
    simg1 = sitk.Cast(sitk.RescaleIntensity(fixed), sitk.sitkUInt8)
    simg2 = sitk.Cast(sitk.RescaleIntensity(out), sitk.sitkUInt8)
    # Use the // floor division operator so that the pixel type is
    # the same for all three images which is the expectation for
    # the compose filter.
    cimg = sitk.Compose(simg1, simg2, simg1 // 2.0 + simg2 // 2.0)
    sitk.Show(cimg, "DeformableRegistration1 Composition")

解决:

注意:fiji软件包的底层环境是java,所以需要提前安装好java哦。

可以再cmd中输入java命令测试,你的系统是否已经安装好了java.

下载fiji软件包:笔者选择windows64位

Fiji Downloads

下载完成之后,解压,会得到一个叫做Fiji.app的文件夹。

将Fiji.app的文件夹拷贝包笔者使用的anaconda主环境的Scripts文件夹中。

D:\\anaconda\\Scripts\\Fiji.app

OK了

完整错误:

(base) C:\\Users\\users>python align.py 1703801.jpg 1703801_1.jpg euler2D.tfm
  1 =  316.08310
  2 =  309.61603
  3 =  305.84348
  4 =  303.55265
  5 =  301.97677
  6 =  300.83932
  7 =  299.98187
  8 =  299.30239
  9 =  298.74999
 10 =  298.26859
 11 =  297.87110
 12 =  297.51645
 13 =  297.20165
 14 =  296.92658
 15 =  296.66421
 16 =  296.44000
 17 =  296.22853
 18 =  296.03984
 19 =  295.86223
 20 =  295.70708
 21 =  295.54896
 22 =  295.39734
 23 =  295.27245
 24 =  295.14585
 25 =  295.02095
 26 =  294.90249
 27 =  294.78907
 28 =  294.69944
 29 =  294.59759
 30 =  294.51432
 31 =  294.42624
 32 =  294.35778
 33 =  294.27413
 34 =  294.21444
 35 =  294.13871
 36 =  294.07736
 37 =  294.01093
 38 =  293.96671
 39 =  293.89736
 40 =  293.85241
 41 =  293.79037
 42 =  293.75224
 43 =  293.69498
 44 =  293.66584
 45 =  293.60078
 46 =  293.57719
 47 =  293.52466
 48 =  293.49716
 49 =  293.45349
 50 =  293.41868
-------
Number Of Iterations: 50
 RMS: 0.25455084462799155
Traceback (most recent call last):
  File "align.py", line 61, in <module>
    sitk.Show(cimg, "DeformableRegistration1 Composition")
  File "D:\\anaconda\\lib\\site-packages\\SimpleITK\\SimpleITK.py", line 7768, in Show
    return _SimpleITK.Show(*args, **kwargs)
RuntimeError: Exception thrown in SimpleITK Show: D:\\a\\1\\sitk\\Code\\IO\\src\\sitkImageViewer.cxx:620:
sitk::ERROR: No ImageJ/Fiji application found.

(base) C:\\Users\\users>

参考:simpleITK

参考:https://blog.csdn.net/weixin_44727457/article/details/109661412
参考:https://blog.csdn.net/Magician0619/article/details/124046418

以上是关于sitk::ERROR: No ImageJ/Fiji application found.的主要内容,如果未能解决你的问题,请参考以下文章

抛弃与修复原理在经济管理中的应用吗

如何使 --no-ri --no-rdoc 成为 gem 安装的默认值? [复制]

如何使用 spark 过滤 Hive 中的记录

Jetpack Compose | Compose 滑动列表真的需要使用LazyColumn吗?No No No!

Jetpack Compose | Compose 滑动列表真的需要使用LazyColumn吗?No No No!

Jetpack Compose | Compose 滑动列表真的需要使用LazyColumn吗?No No No!