【问题标题】:How can Matlab compute the roughness along the boundary of an edge?Matlab 如何计算边缘边界的粗糙度?
【发布时间】:2019-02-27 01:22:19
【问题描述】:

Matlab 如何确定边缘边界的粗糙度?比如Matlab如何判断第一张是光滑的,第二张是粗糙的?

编辑:我还希望 Matlab 能够检测同一图像中哪些边缘是光滑和粗糙的:

【问题讨论】:

    标签: matlab image-processing


    【解决方案1】:

    如果您感兴趣的图像都与您展示的类型相同,那么一种简单的方法可能是(需要图像处理工具箱):

    smooth = imread('smooth.png');
    
    figure(1);
    imshow(smooth);
    
    smoothOpened = (smooth, ones(21));
    
    figure(2);
    imshow(smoothOpened);
    
    smoothDiff = smooth - smoothOpened;
    
    figure(3),
    imshow(smoothDiff);
    
    smoothDifference = sum(smoothDiff(:) > 0)
    
    rough = imread('rough.png');
    
    figure(4);
    imshow(rough);
    
    roughOpened = imopen(rough, ones(21));
    
    figure(5);
    imshow(roughOpened);
    
    roughDiff = rough - roughOpened;
    
    figure(6);
    imshow(roughDiff);
    
    roughDifference = sum(roughDiff(:) > 0)
    
    smoothDifference =  2592
    roughDifference =  11328
    

    (此处省略图像输出。)

    基本上,我们进行形态学打开 (imopen) 以摆脱“尖峰”。您可以改变结构元素的形状和大小。我在这里使用了一个简单的 21 x 21 正方形。之后,我们确定原始图像和“打开”图像之间的差异。大于 0 的像素数可以是“平滑度”或“粗糙度”的近似值。正如我所说,这种方法可能仅适用于问题中显示的图像。

    应该使用二值图像,以便imopen 也生成二值图像。为了简单起见,我使用了通用的uint8 版本,导致xxxOpened 图像中的像素值为0

    【讨论】:

    • 从我的角度来看应该仍然有效。提取两个结构(如果不重叠),并分别应用我的解决方案。当然,您必须为“差异值”的数量相对于单个结构的大小设置某种比率来比较结果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 2021-11-13
    • 1970-01-01
    • 2021-06-02
    • 2021-06-13
    • 2012-08-09
    • 1970-01-01
    相关资源
    最近更新 更多