Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在matlab中实现指定厚度函数_Matlab_Image Processing - Fatal编程技术网

在matlab中实现指定厚度函数

在matlab中实现指定厚度函数,matlab,image-processing,Matlab,Image Processing,我有一个厚度函数,定义为 是一个函数,当两个曲面之间的距离为 在可接受范围内,否则h(x)=0;D、 D和f是常数x是phi矩阵中的值。其他函数c定义为 给定d、d、f和phi。如何用matlab计算h(φ)和c(φ)?我想展示我的实现。你能看一下并给我一些意见吗?谢谢 function h=compute_h(phi) d=1;D=5;f=1; h=zeros(size(phi)); idx1=find(phi<=d&phi>D); idx2=find(

我有一个厚度函数,定义为

是一个函数,当两个曲面之间的距离为 在可接受范围内,否则
h(x)=0
;D、 D和f是常数
x
phi
矩阵中的值。其他函数c定义为

给定
d、d、f和phi
。如何用matlab计算h(φ)和c(φ)?我想展示我的实现。你能看一下并给我一些意见吗?谢谢

function h=compute_h(phi)
  d=1;D=5;f=1;
  h=zeros(size(phi));
  idx1=find(phi<=d&phi>D);
  idx2=find(phi>(d+f)&phi<(D-f));
  idx3=find(phi>d&phi<=(d+f));
  idx4=find(phi>(D-f)&phi<=D);

  h(idx1)=0;
  h(idx2)=1;
  h(idx3)=1-((phi(idx3)-d-f)./f).^2;
  h(idx4)=1-((phi(idx4)-D+f)./f).^2;    
end
%% Defined phi
[Height Wide] = size(Img);% Assume size Img is 11 by 11
[xx yy] = meshgrid(1:Wide,1:Height);
phi = (sqrt(((xx - 3).^2 + (yy - 3).^2 )) - 3);
c=(1-compute_h(abs(phi)).*sign(phi).*sign(abs(phi)-D+f)
函数h=compute_h(φ)
d=1;D=5;f=1;
h=零(尺寸(φ));
idx1=查找(phiD);

idx2=find(phi>(d+f)&phid&phi(d-f)&phi看起来你的思路是对的。不过你不需要使用
find

function C = StackOverflow(Img, d, D, f)
    [Height, Width] = size(Img);% Assume size Img is 11 by 11
    [xx, yy] = meshgrid(1:Width,1:Height);
    phi = (sqrt(((xx - 3).^2 + (yy - 3).^2 )) - 3);
    C = c(phi, d, D, f);
end

function H = h(x, d, D, f)
    H = zeros(size(x));

    c1 = (d + f < x) & (x < D - f);
    c2 = (d < x) & (x <= d + f);
    c3 = (D - f <= x) & (x <= D);

    H(c1) = 1;
    H(c2) = 1 - ((x(c2) - d - f)/(f)).^2;
    H(c3) = 1 - ((x(c3) - D - f)/(f)).^2;

end

function C = c(phi, d, D, f)
    c1 = (abs(phi) >= D - f);
    c2 = (abs(phi) <= d + f);

    C = zeros(size(phi));
    C(c1) = (1 - h(abs(phi(c1)), d, D, f)) .* (sign(phi(c1)));
    C(c2) = (1 - h(abs(phi(c1)), d, D, f)) .* (-sign(phi(c2)));
end
函数C=StackOverflow(Img,d,d,f)
[高度,宽度]=尺寸(Img);%假设尺寸Img为11乘11
[xx,yy]=网格(1:宽度,1:高度);
phi=(sqrt(((xx-3)。^2+(yy-3)。^2))-3);
C=C(φ,d,d,f);
结束
函数H=H(x,d,d,f)
H=零(尺寸(x));
c1=(d+fc2=(d