当我们有tfrom时如何获得位移场或控制点向量? [英] How to get displacement field or control point vector when we have tfrom?

查看:232
本文介绍了当我们有tfrom时如何获得位移场或控制点向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用图像注册工具箱来注册两个3D图像。我将运动图像注册到固定图像。我使用imregtform来保存tform。

  tform = imregtform(moving,fixed,transformType,optimizer,metric)

例如这是我的'tform':

  1.0235 0.0022 -0.0607 0 
-0.0276 1.0002 0.0089 0
-0.0170 -0.0141 1.1685 0
12.8777 5.0311 -70.0325 1.0000

然后我使用'Imwarp'将运动图像传输到固定图像。在我的代码中,

  nii = load_untouch_nii(['mypath image.nii']); 
I = nii.img;
dii = nii.hdr.dime.pixdim(2:4);
Rfixed = imref3d(size(I),dii(2),dii(1),dii(3));
timg = imwarp(I,Rfixed,tform,'OutputView',Rfixed);

'timg'是源图像的转移图像。我检查了它并且工作正常,但我现在需要这种转变的控制点或位移场。换句话说,我需要知道每个体素(3d像素)移动到哪个位置。如果我知道这个我可以绘制矢量场。在可变形的图像注册方法(如 NiftyReg包)中,提供了控制点命令,以方便用户使用我不知道如何在Matlab中使用简单的3d仿射。
任何帮助都会受到太多赞赏

解决方案

您可以非常轻松地将几何变换应用于单个点。 / p>

您只需将您的点定义为 p = [x; y; z; 1]



然后通过获得 pt pt = p * tform; pt = pt(1:3)./ pt(4); (搜索齐次坐标以解释最后一个除法)。这就是内部的 imwarp 。它为每个像素执行所述乘法 p



要获得位移,您只需要 DISP = PT-p; 。请注意,位移很可能不是整数。



请注意,在可变形图像注册领域,通常会有不同的 tform 为每个控制点(这就是为什么它被称为可变形而非僵硬)



编辑:正如@Ashish Uthama建议的那样在评论中,您也可以使用Matlab内置函数 transformpointsforward()来完成。我将永远是编写自己的代码理念的推动者,特别是第一次,所以你明白你在做什么。



http://uk.mathworks.com/help/images/ref/affine3d.transformpointsforward.html


I am using image registration toolbox to register two 3D images. I register the moving image to the fixed image. I use "imregtform" to save tform.

tform = imregtform(moving,fixed,transformType,optimizer,metric)

for example this is my 'tform':

    1.0235    0.0022   -0.0607         0
   -0.0276    1.0002    0.0089         0
   -0.0170   -0.0141    1.1685         0
   12.8777    5.0311  -70.0325    1.0000

then I use 'Imwarp' to transfer moving image to the fixed image. In my code it is,

nii=load_untouch_nii(['mypath image.nii' ]);
I = nii.img; 
dii=nii.hdr.dime.pixdim(2:4);
Rfixed=imref3d(size(I),dii(2),dii(1),dii(3)); 
timg= imwarp(I, Rfixed, tform, 'OutputView', Rfixed);

'timg' is transfered image of source image.I checked it and it is working fine, but I need control points or displacement field of this transformation now. In another word, I need to know each voxel(3d pixel) moved to which position. If I know this I can draw vector field. In deformable image registartion methods such as NiftyReg package, control point command is provided to make it easy for users but I do not know how to do it in simple 3d affine in Matlab. Any help will be appreciated too much

解决方案

You can apply your geometric transform to a single point very easily.

You just need to have your point defined as p=[x;y;z;1]

and then obtain pt by pt=p*tform; pt=pt(1:3)./pt(4); (search for homogeneous coordinates for explanation of this last division). This is what imwarp does in the inside. It performs the said multiplication for each pixel p.

To then obtain the displacement, you would need just to disp=pt-p;. Note that the displacements are most likely not integer.

Note that in the field of deformable image registration, generally you will have a different tform for each control point (that is why it is called deformable and not rigid)

EDIT: as @Ashish Uthama suggests in the comments, you can also do it with Matlab inbuilt function transformpointsforward(). I will always be a promoter of "writing your own code" philosophy, specially the first time, so you do understand what are you actually doing.

http://uk.mathworks.com/help/images/ref/affine3d.transformpointsforward.html

这篇关于当我们有tfrom时如何获得位移场或控制点向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆