image - How to get displacement field or control point vector when we have tfrom? -
i using image registration toolbox register 2 3d images. register moving image fixed image. use "imregtform" save tform.
tform = imregtform(moving,fixed,transformtype,optimizer,metric) for example '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 use 'imwarp' transfer moving image fixed image. in code is,
nii=load_untouch_nii(['mypath image.nii' ]); = 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' transfered image of source image.i checked , working fine, need control points or displacement field of transformation now. in word, need know each voxel(3d pixel) moved position. if know can draw vector field. in deformable image registartion methods such niftyreg package, control point command provided make easy users not know how in simple 3d affine in matlab. appreciated
you can apply geometric transform single point easily.
you need have point defined p=[x;y;z;1]
and obtain pt pt=p*tform; pt=pt(1:3)./pt(4); (search homogeneous coordinates explanation of last division). imwarp in inside. performs said multiplication each pixel p.
to obtain displacement, need disp=pt-p;. note displacements not integer.
note in field of deformable image registration, have different tform each control point (that why called deformable , not rigid)
edit: @ashish uthama suggests in comments, can matlab inbuilt function transformpointsforward(). promoter of "writing own code" philosophy, specially first time, understand doing.
http://uk.mathworks.com/help/images/ref/affine3d.transformpointsforward.html
Comments
Post a Comment