0

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

我想将其转换为折线轮廓,例如:dot-line-space-dot-line-space 等。

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

4

1 回答 1

4

您可以先使用 填充对象imfill,然后使用 对其进行跟踪,并使用给定的线条样式bwboundaries绘制结果。plot

% 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 点。那好吧!只需使用LineStyleplot 的属性来完成您想要的。

于 2016-09-19T16:47:16.610 回答