2016-05-31 111 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

是的。謝謝。 –