2016-09-19 103 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屬性來完成你想要的。