2016-05-31 114 views
1

我想问一个关于分割二进制图像的问题。我试着用下面的代码:如何在Matlab中将图像划分为更小的部分(绘图)

%# FAPatch is the binary image  
figure,imshow(FAPatch) 
hold on 

%# PositionTab is a table that include the 3 outest point. 
for i=1 :3 
    eval(['p' num2str(i) '= PositionTab(' num2str(i) ',:);']); 
end 

%#C is the centroid [130,59]. And this is the code I use to draw the lines from centroid to the point 
plot([C(1),p1(2)],[C(2),p1(1)],[C(1),p2(2)],[C(2),p2(1)],[C(1),p3(2)],[C(2),p3(1)],'Color','r','LineWidth',2) 

这是表:

PositionTab

我得到一个二进制图象行:

binary image with line

如何分割这个图像分成三小块?这不是一条直线,可以是随机的,我找不到解决方案。

+0

我的回答是否解决了您的问题?如果是这样,请考虑接受它作为您的答案 - 通过点击投票计数旁边的空心绿色勾号/复选标记。如果没有,请说出什么不起作用,以便我或其他人可以进一步帮助您。谢谢。 http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 –

回答

0

我觉得这是你的意思......

转到每个地方的红线满足图像的边缘三点。使用立即上下的点,如果在垂直边上,或者立即在左边和右边的点(如果在水平边上)作为红色填充的种子,现在使所有红色点透明。

enter image description here

+0

是的。谢谢。 –