2013-05-31 24 views
0

Binary Image圓和二進制圖像的交點MATLAB

我有骷髏二進制圖像和聯結信息。我想以交點爲中心繪製圓,並且想要找到圓和二值圖像的交點。 我寫了下面的代碼:

BW = imread('circles.png'); 
imshow(BW); 
BW2 = bwmorph(BW,'remove'); 
figure, imshow(BW2) 
BW3 = bwmorph(BW,'skel',Inf); 
figure, imshow(BW3) 
BW3t = bwmorph(BW3,'thin'); 
figure, imshow(BW3t) 


[rj, cj, re, ce] = findendsjunctions(BW3t, 1); 
hold on 
plot(cj(1),rj(1),'ob') 
hold on 
circle([cj(1),rj(1)],4,50,':r'); 

findendsjunctions.m和相關的文件show.m可以從這裏下載:http://www.csse.uwa.edu.au/~pk/research/matlabfns/LineSegments/findendsjunctions.m分別這裏http://www.csse.uwa.edu.au/~pk/research/matlabfns/Misc/show.m。 和circle.m可以從這裏下載:http://www.mathworks.co.uk/matlabcentral/fileexchange/2876-draw-a-circle/content/circle.m

我想知道圓是否與它周圍的2,3或4條容器相交(標記爲圖像中的星號)。即使單個船隻橫向多次旋轉但輸出應該是每個船隻的一個交點。

請建議如何找到圓形和二元船的交集。

感謝

+0

和您的問題?你迄今爲止試圖做什麼?你有其他代碼的鏈接,實現這些代碼有什麼問題? – bla

+0

@natan上面的代碼實現沒有問題,但我的下一步是找到圓和二進制圖像的交點。我想找到圓圈與二元容器相交處的3個點(標記爲圖像中的星號)。你可以建議如何? – Dev

+0

請參閱安德烈的網頁:https://matlabcorner.wordpress.com/ – bla

回答

0

我發現圈和二進制圖像和3點(標記爲帶有我的問題在圖像中星)座標的交叉點。我有改變功能circle.m(在上面我的問題提到的)給所有X的輸出和圓的周長的Y座標,然後我寫了下面的MATLAB代碼:

[H, X, Y]=circle([cj(1),rj(1)],4,50,':r'); 
    c = improfile(BW3t,X,Y) 
    x=1:length(c) 
    figure 
    plot(x, c,'r') 

Number of peaks represent where circle cuts the binary image

[maxtab, mintab]=peakdet(c, 1) 
    [pks,locs] = findpeaks(c) 
    pt1=[X(locs(1)) Y(locs(1))] 
    pt2=[X(locs(2)) Y(locs(2))] 
    pt3=[X(locs(3)) Y(locs(3))] 

    hold on 
    plot(pt1(1),pt1(2),'om','LineWidth',2) 
    hold on 
    plot(pt2(1),pt2(2),'og','LineWidth',2) 
    hold on 
    plot(pt3(1),pt3(2),'ob','LineWidth',2) 

pt1,pt2 pt3是圓形切割二進制圖像的三個點