Como pontos de transferência imatura no Matlab?

Estou usando o Matlab para transformar uma imagem em uma imagem de destino. Eu tenho transformação geométrica (tform).

por exemplo, esta é a minha 'forma':

    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

No Matlab2013, é possível fazer isso facilmente usando o imwarp:

%nii = 3D MR Image
I = nii.img; 
dii=nii.hdr.dime.pixdim(2:4);
Rfixed=imref3d(size(I),dii(2),dii(1),dii(3));    
new_img= imwarp(old_img, Rfixed, tform, 'OutputView', Rfixed);

o resultado é perfeito usando o iwarp (pulmão vermelho na imagem)

Eu preciso saber como o imwarp está funcionando, então eu escrevi minha própria função

function [new_img] = aff3d(old_img, tform, range_x, range_y, range_z)

   [U, V, W] = ndgrid(range_x, range_y, range_z);
   xyz = [reshape(U,[],1)';reshape(V,[],1)';reshape(W,[],1)'];
   xyz = [xyz; ones(1,size(xyz,2))];


   uvw = tform.T * xyz;
   % avoid homogeneous coordinate  
   uvw = uvw(1:3,:)';


   xi = reshape(uvw(:,1), length(range_x),length(range_y),length(range_z));
   yi = reshape(uvw(:,2), length(range_x),length(range_y),length(range_z));
   zi = reshape(uvw(:,3), length(range_x),length(range_y),length(range_z));

   old_img = single(old_img);
   new_img = interp3(old_img,yi,xi,zi,'linear');

   ii = find(isnan(new_img));
   if(~isempty(ii))
      new_img(ii) = 0;
   end
end

o resultado da minha função (mais informações) não é compatível com a saída imwarp (o pulmão vermelho não está localizado no local correto), alguém pode me ajudar?

,

questionAnswers(1)

yourAnswerToTheQuestion