在Matlab图像中将轮廓转换为虚线

时间:2016-09-19 16:41:53

标签: matlab contour dotted-line

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

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

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

1 个答案:

答案 0 :(得分: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 绘制结果。

LineStyle

a given line style

<强>更新

哦......你已经有了x / y分。那好吧!只需使用plot的and属性即可完成您想要的任务。