我有一个3D数据集和一个2D数据集,它是第一个卷的切片.它们处于不同的尺度,分辨率和不同的坐标系中,但我知道仿射变换到世界坐标.然后我想我知道如何应用这些,但是如何使用sinc插值再次从那些变换坐标中获取图像?我想学习如何执行此操作/如何工作.下面的第一条评论已经指出我在matlab中执行线性插值的现有函数,但我也想知道如何自己这样做,所以我可以使用sinc插值(和其他).
我可以对坐标进行舍入并获得那些值,这将是最近邻插值.我想尽可能少地丢失信息而不管计算时间,我想我应该使用sinc插值.当我有变换后的坐标时,如何制作(例如sinc)插值算法?
例如:
%%get data
A = rand(200,250,250); % I want to get the slice from this that corresponds to B
B = rand(1200,1200); % I want to get the data from A that corresponds to the same pixels
%%get coordinates for A
siza = size(A); clear xx;clear yy;clear zz;
[xx,yy,zz] = meshgrid(1:siza(1), 1:siza(2), 1:siza(3));
coora = [xx(:)';yy(:)';zz(:)'; ones(size(zz(:)))'];
%%get coordinates for B
sizb = size(B); clear xx;clear yy;clear zz;
[xx,yy] = meshgrid(1:sizb(1),1:sizb(2)); zz = zeros(size(xx));
coorb = [xx(:)';yy(:)';zz(:)'; ones(size(zz(:)))'];
%%define affine transformation matrices
T3d = [-0.02 0.02 1 -88 ;
-0.98 0 -0.02 130;
0 0.98 -0.02 -110;
0 0 0 1 ];
T2d = [-0.2 0 0 126;
0 0.2 -0.2 -131;
0 0 2 43 ;
0 0 0 1 ];
%%transform A coordinates to world coordinates and world coordinates to B coordinates
cooraInBref = T3d*inv(T2d)*coora;
aslice = zeros(size(B));
%% then nearest neighbor would go something like this (dont exactly know how to do this either):
cooraInBround = round(cooraInBref);
for idx = 1:length(coorb);
if cooraInBround(3,idx) == 0
aslice(cooraInBround(1,idx),cooraInBround(2,idx)) = ...;% dont know how to do this
end
end
%% how would I implement sinc interpolation instead of rounding the transformed coordinates
相关问题对我没有任何帮助:
准备使用matlab中的函数,如chappjc anonsubmitter85和cape代码的评论中所指出:
使用scatInterpolant正如评论中所建议的那样,链接的问题花费了大约十分钟,并且导致了所有NaN的切片,现在正在尝试其他方法.