Interpolating or resampling algorithm in matlab for transformed 3D image, preferably sinc interpolation

后端 未结 1 698
谎友^
谎友^ 2020-12-21 13:42

I have one 3D dataset and one 2D dataset which is a slice through the first volume. They are at different scales, resolutions and in a different coordinate system, but of bo

相关标签:
1条回答
  • 2020-12-21 14:16

    I now start the other way around: get the 2d points to sample and then transform those to the 3d volume and then use interp3 to calculate the values. Its pretty quick and works well. This code only works for getting a single slice, but i think you can easily adapt it to get a whole transformed volume. I still dont know how to do sinc interpolation though.

    %% transformation from one image to the other
    Affine = inv(T2d)*T3d
    
    %% get coordinates for B
    sizb = size(B); clear xx;clear yy;clear zz;
    [xx,yy] = meshgrid(1:sizb(1),1:sizb(2)); 
    zz = ones(size(xx));
    coorb = [xx(:)';yy(:)';zz(:)'; ones(size(zz(:)))'];
    
    %% transformed coordinates
    coorb_t = Affine*coorb;
    idxX = reshape(coorb_t(:,1), sizb(1), sizb(2), 1);
    idxY = reshape(coorb_t(:,2), sizb(1), sizb(2), 1);
    idxZ = reshape(coorb_t(:,3), sizb(1), sizb(2), 1);
    
    %% interpolate
    Asliced = interp3(A, idxX, idxY, idxZ, 'cubic');
    

    Still not sure if I should have used zeros or ones for Z.

    0 讨论(0)
提交回复
热议问题