2011-03-11 75 views

回答

2

您可以簡單地使用bwtraceboundary,這裏是例子:


BW = imread('blobs.png'); 
imshow(BW,[]); 
s=size(BW); 
for row = 2:55:s(1) 
    for col=1:s(2) 
     if BW(row,col), 
     break; 
     end 
    end 

    contour = bwtraceboundary(BW, [row, col], 'W', 8, 50,... 
            'counterclockwise'); 
    if(~isempty(contour)) 
     hold on; 
     plot(contour(:,2),contour(:,1),'g','LineWidth',2); 
     hold on; 
     plot(col, row,'gx','LineWidth',2); 
    else 
     hold on; plot(col, row,'rx','LineWidth',2); 
    end 
end 
+0

我已經嘗試過這一點,但它沒有工作!我感謝你的努力.. – junto 2011-03-15 07:10:01

+0

在我的電腦工作,它有什麼問題? – MBZ 2011-03-15 15:34:31

+3

@junto:不,你說它「沒有工作」。 – 2011-04-07 11:37:40