Problems with interp3
显示 更早的评论
Hi everybody!:
I have a matrix whose dimensions are 512x512x56(Cube_CT), every image have a voxel whose dimensions are 0.97x0.97 (mm) and the SliceThickness is 3mm, and I need that every image has a voxel with dimensions: 0.97x0.97(mm) and the SliceThickness 1mm. My code is the following:
[m,n,p]=size(Cube_CT);
[X,Y,Z]=meshgrid(1:m,1:n,1:p);
voxel_x_in=InfoCT_ord{1,1}.PixelSpacing(1);
voxel_y_in=InfoCT_ord{1,1}.PixelSpacing(2);
voxel_z_in=InfoCT_ord{1,1}.SliceThickness;
voxel_x_out=InfoCT_ord{1,1}.PixelSpacing(1);
voxel_y_out=InfoCT_ord{1,1}.PixelSpacing(2);
voxel_z_out=1;
xx=(voxel_x_out/voxel_x_in:voxel_x_out/voxel_x_in:m);
yy=(voxel_y_out/voxel_y_in:voxel_y_out/voxel_y_in:n);
zz=(voxel_z_out/voxel_z_in:voxel_z_out/voxel_z_in:p);
[Xq,Yq,Zq]=meshgrid(xx,yy,zz);
CubeCT_inter=interp3(X,Y,Z,Cube_CT,Xq,Yq,Zq,'cubic');
But when I execute this code, all components of the first image and second image are NaN. I don't understand where is the problem.
Thanks!
回答(1 个)
Walter Roberson
2016-4-30
0 个投票
I recommend you use linspace() instead of the colon operator to build the xx, yy, zz
2 个评论
Walter Roberson
2016-5-1
Which is the "first" image, and which is the "second" image?
类别
在 帮助中心 和 File Exchange 中查找有关 Images 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!