How to get mask from boundary()
16 次查看(过去 30 天)
显示 更早的评论
Hi,
I have points that represents curve levels. With thoses, I can find the boundary (k) matrix:
x = [1 2 3 4 3 2];
y = [4 5 5 4 3 3];
k = boundary(x,y);
I would like to make a mask from this boundary, but the function "boundary" does not provide the same output that "bwboundaries" does. Therefore, I cannot make a mask.
So, how can I make a mask with this data?
0 个评论
采纳的回答
KSSV
2019-2-20
x = [1 2 3 4 3 2]';
y = [4 5 5 4 3 3]';
k = boundary(x,y);
plot(x,y,'.r')
hold on
patch(x(k),y(k),'k')
7 个评论
KSSV
2019-2-21
x = [1 2 3 4 3 2]';
y = [4 5 5 4 3 3]';
k = boundary(x,y);
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
[X,Y] = meshgrid(linspace(x0,x1),linspace(y0,y1)) ;
idx = inpolygon(X(:),Y(:),x(k),y(k)) ;
% X(~idx) = NaN ;
% Y(~idx) = NaN ;
plot(x,y,'.r')
hold on
patch(x(k),y(k),'k') ;
plot(X(idx),Y(idx),'.r')
plot(X(~idx),Y(~idx),'.b')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bounding Regions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!