【问题标题】:Convert contour to broken line in image Matlab在图像Matlab中将轮廓转换为虚线
【发布时间】:2016-09-19 16:41:53
【问题描述】:

我在 Matlab 中遇到以下问题:我有一个 2D 闭合轮廓(一组 2D 点坐标)表示像此图像中的对象:

我想把它转换成折线轮廓,比如:dot-line-space-dot-line-space等

有没有办法在 Matlab 中解决这个问题? 非常感谢你

【问题讨论】:

    标签: matlab contour dotted-line


    【解决方案1】:

    您可以先使用imfill 填充对象,然后使用bwboundaries 跟踪它,并使用plota given line style 绘制结果。

    % Load the image in and convert to binary
    img = imread('http://i.stack.imgur.com/G4NLh.png');
    img = img(:,:,1) > 170;
    
    % Fill in the middle hole and compute the boundary
    boundary = bwboundaries(imfill(img, 'holes'));
    
    % Plot the boundary on a black background
    plot(boundary{1}(:,2), boundary{1}(:,1), ...
                'LineStyle', '-.', ...
                'Marker', 'none')
    
    axis image
    axis ij
    

    更新

    哦……你已经有了 x/y 点。那好吧!只需使用 plot 的 LineStyle 属性即可完成您想要的操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-29
      • 2011-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多