码迷,mamicode.com
首页 > 其他好文 > 详细

ANTsPy医学图像配准

时间:2020-02-14 18:52:29      阅读:364      评论:0      收藏:0      [点我收藏+]

标签:接受   www   download   支持   field   idt   bsp   fast   sync   

ANTsPy主页:https://github.com/ANTsX/ANTsPy

ANTsPy官方文档:https://antspyx.readthedocs.io/_/downloads/en/latest/pdf/

 

配准ants.registration()

import os
import ants
import numpy as np
import time

fix_path = ‘img_fix.png‘
move_path = ‘img_move.png‘

# 配准所使用的各种方法 各方法耗时:https://www.cnblogs.com/JunzhaoLiang/p/12308200.html
types = [‘Translation‘, ‘Rigid‘, ‘Similarity‘, ‘QuickRigid‘, ‘DenseRigid‘, ‘BOLDRigid‘, ‘Affine‘, ‘AffineFast‘, ‘BOLDAffine‘, ‘TRSAA‘, ‘ElasticSyN‘, ‘SyN‘, ‘SyNRA‘, ‘SyNOnly‘, ‘SyNCC‘, ‘SyNabp‘, ‘SyNBold‘, ‘SyNBoldAff‘, ‘SyNAggro‘, ‘TVMSQ‘]
# 保存为png只支持unsigned char & unsigned short,因此读取时先进行数据类型转换 fix_img
= ants.image_read(fix_path, pixeltype=‘unsigned char‘) move_img = ants.image_read(move_path, pixeltype=‘unsigned char‘) for t in types: start = time.time() out = ants.registration(fix_img, move_img, type_of_transform=t) reg_img = out[‘warpedmovout‘] # 获取配准结果 reg_img.to_file(t+‘.png‘) print(t+‘ : ‘, time.time()-start, ‘\n‘)

技术图片技术图片技术图片技术图片技术图片技术图片技术图片

  ‘Translation‘     ‘Rigid‘       ‘Similarity‘     ‘QuickRigid‘     ‘DenseRigid‘     ‘BOLDRigid‘       ‘Affine‘

技术图片技术图片技术图片技术图片技术图片技术图片技术图片

  ‘AffineFast‘     ‘BOLDAffine‘      #TRSAA#      ‘ElasticSyN‘       ‘SyN‘          ‘SyNRA‘        ‘SyNOnly‘

技术图片技术图片技术图片技术图片技术图片技术图片 

  ‘SyNCC‘        ‘SyNabp‘        ‘SyNBold‘      ‘SyNBoldAff‘      ‘SyNAggro‘      ‘TVMSQ‘

技术图片 技术图片

   ‘img_2‘        ‘img_1‘

校正偏置场ants.n4_bias_field_correction()

import os
import ants
import numpy as npimport time

move_path = ‘img.png‘
move_img = ants.image_read(move_path, pixeltype=‘unsigned char‘)

n4_img = ants.n4_bias_field_correction(move_img)
n4_img = ants.from_numpy(np.array(n4_img.numpy(), dtype=‘uint8‘))
# png只接受 unsigned char & unsigned short
# 保存之前需转换类型

n4_img.to_file(‘TRSAA_n4.png‘)

 技术图片技术图片技术图片技术图片

     ‘OG‘        ‘OG_n4‘         ‘TRSAA‘         ‘TRSAA_n4‘    

ANTsPy医学图像配准

标签:接受   www   download   支持   field   idt   bsp   fast   sync   

原文地址:https://www.cnblogs.com/JunzhaoLiang/p/12308186.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!