【问题标题】:MATLAB 2015b: "sphere" not recognized in strel commandMATLAB 2015b:在 strel 命令中无法识别“球体”
【发布时间】:2018-04-04 02:30:53
【问题描述】:

我有一个 3d 二进制图像,我试图在 MATLAB 2015b 中对其进行 3d 膨胀。我试过了:

se=strel('sphere',20);
3Ddilated=imdilate(3Dimage,se);

但我得到了:

Error using strel>ParseInputs (line 1223)
Expected input number 1, STREL_TYPE, to match one of these strings:

'arbitrary', 'square', 'diamond', 'rectangle', 'octagon', 'line', 'pair', 'periodicline', 'disk', 'ball'

The input, 'sphere', did not match any of the valid strings.

Error in strel (line 147)
                [type,params] = ParseInputs(varargin{:});

strel 在 2015b 中不做 'sphere' 吗?有什么好的选择吗?

【问题讨论】:

    标签: matlab 3d binary


    【解决方案1】:

    您可以自己生成与strel'sphere' 选项相同的3D 球形结构元素。在 MATLAB R2016b 中进行测试:

    radius = 5;
    
    sphereSE = strel('sphere', radius);  % Spherical element
    
    [x, y, z] = ndgrid(-radius:radius);
    arbitSE = strel(sqrt(x.^2+y.^2+z.^2) <= radius);  % The `arbitrary` argument is optional
    
    isequal(sphereSE.Neighborhood, arbitSE.Neighborhood)  % Check equality
    
    ans =
    
      logical
    
       1  % They give the same result
    

    【讨论】:

    • 谢谢,我正在尝试这个,膨胀需要一段时间..愚蠢的几何问题:我应该期望在半径=10 的球体上进行 3d 膨胀而不是在 2d 中通过 2d 图像迭代得到不同的结果3d 集和半径 = 10 的 2d 圆扩张(速度更快)?
    • @user3470496:使用 2D 磁盘元素对堆栈中的每个 2D 图像进行扩张与使用球体进行 3D 扩张不同。它更快,但操作不同。
    【解决方案2】:

    您可以自己创建一个:

    r = 20;
    x = -r:r;
    x = x.^2;
    [x,y,z]=ndgrid(x,x,x);
    se = (x+y+z) <= r.^2;
    

    【讨论】:

      猜你喜欢
      • 2016-10-21
      • 1970-01-01
      • 2014-06-15
      • 2020-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多