Binary matrix to array of poitns
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have a binary image (only 0 and 1) and I want to convert it to x-y arrays.
For example:
Matrix
0 1 0 1
0 0 0 1
1 0 0 0
0 0 0 0
Obtain:
x = [1 1 2 3];
y = [2 4 4 1];
I can do it with two loops, but I'm finding something more fast. Thanks
0 个评论
更多回答(1 个)
CS Researcher
2016-5-4
Do the x and y arrays have to be in that order? If not, you can do this:
[x,y] = find(A>0);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!