Matlab 三维空间中两个平面之间的插值

Matlab 三维空间中两个平面之间的插值,matlab,math,3d,contour,spatial-interpolation,Matlab,Math,3d,Contour,Spatial Interpolation,我正在开发一个工具,可以让你在一个3d“体积”上圈出/圈出东西。我想通过标记“切片”1和3,以及从这些信息中“填充”切片2来节省时间 两个简单的解决方案是: 1. slice2 = slice1 AND slice3 (gets the overlap between the two) 2. slice2 = slice2 OR slice3 (true for any pixel true in either image) 这些都是好的和快速的,但我更愿意做一些更智能的事情,通过使形状在两

我正在开发一个工具,可以让你在一个3d“体积”上圈出/圈出东西。我想通过标记“切片”1和3,以及从这些信息中“填充”切片2来节省时间

两个简单的解决方案是:

1. slice2 = slice1 AND slice3 (gets the overlap between the two)
2. slice2 = slice2 OR  slice3 (true for any pixel true in either image)
这些都是好的和快速的,但我更愿意做一些更智能的事情,通过使形状在两者之间进行某种平均/插值。 你可以把它想象成试图找到悬崖面,它连接着一个水平面上的飞机和空中的高原

示例:填充此3d矩阵中的切片2-4。(使用蒙太奇创建)

随时提出全新的想法。我将把我的想法放在下面

回答者,我想了一些可能对你有帮助的东西,但我还没能成功使用
-你可以在每张图片上做一次bwperim
-您可以尝试对图像进行“平均”(或加权平均)。

到目前为止我得到的最好的:

添加图像。 提供重叠和两个周长:
-内周长(内周长一定为1)
-以及外围(内部值得怀疑)

你也可以遮罩>0的区域,我今天在阅读了以下内容后发现了这一点: Schenk等人的“医学图像中3D对象的高效半自动分割”

以下是我编写的函数:

function out = interp_shape(top,bottom,num)


if nargin<2;
    error('not enough args');
end
if nargin<3;
    num = 1;
end
if ~num>0 && round(num)== num; 
    error('number of slices to be interpolated must be integer >0');
end

top = signed_bwdist(top); % see local function below
bottom = signed_bwdist(bottom);

r = size(top,1);
c = size(top,2);
t = num+2;

[x y z] = ndgrid(1:r,1:c,[1 t]); % existing data
[xi yi zi] = ndgrid(1:r,1:c,1:t); % including new slice

out = interpn(x,y,z,cat(3,bottom,top),xi,yi,zi);
out = out(:,:,2:end-1)>=0;

function im = signed_bwdist(im)
im = -bwdist(bwperim(im)).*~im + bwdist(bwperim(im)).*im;
function out=interp_形状(顶部、底部、数字)
如果nargin=0;
函数im=signed_bwdist(im)
im=-bwdist(bwperim(im)).~im+bwdist(bwperim)(im)).*im;

今天,在阅读了以下内容后,我明白了这一点: Schenk等人的“医学图像中3D对象的高效半自动分割”

以下是我编写的函数:

function out = interp_shape(top,bottom,num)


if nargin<2;
    error('not enough args');
end
if nargin<3;
    num = 1;
end
if ~num>0 && round(num)== num; 
    error('number of slices to be interpolated must be integer >0');
end

top = signed_bwdist(top); % see local function below
bottom = signed_bwdist(bottom);

r = size(top,1);
c = size(top,2);
t = num+2;

[x y z] = ndgrid(1:r,1:c,[1 t]); % existing data
[xi yi zi] = ndgrid(1:r,1:c,1:t); % including new slice

out = interpn(x,y,z,cat(3,bottom,top),xi,yi,zi);
out = out(:,:,2:end-1)>=0;

function im = signed_bwdist(im)
im = -bwdist(bwperim(im)).*~im + bwdist(bwperim(im)).*im;
function out=interp_形状(顶部、底部、数字)
如果nargin=0;
函数im=signed_bwdist(im)
im=-bwdist(bwperim(im)).~im+bwdist(bwperim)(im)).*im;

使用'bwmorph(mask,'skel',inf)可以得到一个确定的答案。为了实现这一点,我将把它应用于切片[15],得到切片3。然后切片[13]得到2…使用'bwmorph(mask,'skel',inf)可以得到一个确定的答案。为了实现这一点,我将把它应用于切片[15],得到切片3。然后切片[13]得到2。。。