2016-09-19 101 views
0

我已经在Matlab中存在以下问题:我有一个2D闭合轮廓(点的一组2D的坐标)表示像这样的图像中的对象: image representing 2D contour转换轮廓在图像虚线Matlab的

我想把它转换成像下面这样的虚线:dot-line-space-dot-line-space等

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

回答

4

您可以使用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 

enter image description here

更新

哦......你已经有X/Y点。好吧!只需使用阴谋的LineStyle属性来完成你想要的。