我已經(jīng)從源代碼安裝了 Python3 上的 SimpleITK 包。當(dāng)我執(zhí)行提供的注冊(cè)示例時(shí):#!/usr/bin/env python #=========================================================================## Copyright NumFOCUS## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0.txt## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.##=========================================================================from __future__ import print_functionimport SimpleITK as sitkimport sysimport osdef command_iteration(method) : print("{0:3} = {1:10.5f} : {2}".format(method.GetOptimizerIteration(), method.GetMetricValue(), method.GetOptimizerPosition()))if len ( sys.argv ) < 4: print( "Usage: {0} <fixedImageFilter> <movingImageFile> <outputTransformFile>".format(sys.argv[0])) sys.exit ( 1 )fixed = sitk.ReadImage(sys.argv[1], sitk.sitkFloat32)moving = sitk.ReadImage(sys.argv[2], sitk.sitkFloat32)R = sitk.ImageRegistrationMethod()R.SetMetricAsMeanSquares()R.SetOptimizerAsRegularStepGradientDescent(4.0, .01, 200 )R.SetInitialTransform(sitk.TranslationTransform(fixed.GetDimension()))R.SetInterpolator(sitk.sitkLinear)R.AddCommand( sitk.sitkIterationEvent, lambda: command_iteration(R) )在寫(xiě)入圖像并觸發(fā)以下錯(cuò)誤之前,執(zhí)行Python ImageRegistrationMethod1.py image_ref.tif image_moving.tif res.tif似乎運(yùn)行良好:res.tif
2 回答

慕尼黑的夜晚無(wú)繁華
TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超6個(gè)贊
運(yùn)行 ImageRegistrationMethod1 示例的結(jié)果是一個(gè)轉(zhuǎn)換。SimpleITK 支持多種文件格式進(jìn)行轉(zhuǎn)換,包括文本文件 (.txt)、Matlab 文件 (.mat) 和 HDF5Tranform (.hdf5)。這不包括 .tif 文件,這是一個(gè)圖像文件,而不是轉(zhuǎn)換。
您可以在 SimpleITK IO 頁(yè)面的轉(zhuǎn)換部分閱讀更多相關(guān)信息:
https://simpleitk.readthedocs.io/en/master/IO.html#transformations
在這個(gè)例子中,產(chǎn)生的變換是一個(gè) 3-d 平移。因此,如果您選擇了 .txt 文件輸出,您可以在參數(shù)行中看到 X、Y 和 Z 翻譯。

偶然的你
TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊
如果你想寫(xiě) dicom 作為文件輸出,請(qǐng)?jiān)囋囘@個(gè)。
writer.SetFileName(os.path.join('transformed.dcm')) writer.Execute(cimg)
添加回答
舉報(bào)
0/150
提交
取消