2013-05-31 27 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是圆形切割二进制图像的三个点