我在Matlab中遇到以下问题:我有一个2D闭合轮廓(一组2D坐标点),表示这个图像中的对象:
我想将其转换为虚线轮廓,如:dot-line-space-dot-line-space等。
有没有办法在Matlab中解决这个问题? 非常感谢你
答案 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
<强>更新强>
哦......你已经有了x / y分。那好吧!只需使用plot的and
属性即可完成您想要的任务。