bwboundaries : missing coordinates of one of the two borders of my image
조회 수: 1 (최근 30일)
이전 댓글 표시
HI,
I have a problem with the function bwboundaries. When I use it with a black and white image (containing 2 pores), I can extract only the coordinates of a single border (whereas I have two). The plot gives me two disctinct border.
How can I have the coordinates for both borders?
I put the short code and the picture below.
Thank you
Image = imread('GDgeoRE2.bmp');
I = im2bw(Image);
Ifill = imfill(I,'holes');
B = bwboundaries(Ifill);
for k = 1:length(B)
b = B{k};
plot(b(:,1),b(:,2),'r','linewidth',2);
end
c1 = downsample(b(:,1),1);
c2 = downsample(b(:,2),1);
disp(b)
disp(c1)
disp(c2)
댓글 수: 0
답변 (1개)
Guillaume
2019년 9월 18일
편집: Guillaume
2019년 9월 18일
The problem has nothing to do with bwboundary. The problem is with you calling plot in a loop without hold on, so each time you call plot it erases the previous plot. Hence you're left with just the last boundary plot.
figure;
hold on;
for k = 1:length(B)
b = B{k};
plot(b(:,1),b(:,2),'r','linewidth',2);
end
would fix that.
댓글 수: 3
Guillaume
2019년 9월 18일
I don't really understand what you are saying.
You could indeed concatenate all the boundaries into one array and plot it all at once but you'll get a line linking all the boundaries.
The concatenation can be done more efficiently without a loop:
v = [B{:}];
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!