Find indices of a binary matrix depicting a circular disk in the clockwise direction
1 次查看(过去 30 天)
显示 更早的评论
I have a binary matrix of a circular disk. I need to find the indices of all the ones in the matrix. However, I am trying to find it sequentially in the clockwise/anticlockwise direction. I have used the find fuction. But that gives me the indices in the row by row or column by column sequence rather than circumferentially. Any help will be appreciated
0 个评论
采纳的回答
Walter Roberson
2020-6-12
[rows, cols] = find(YourImage);
%find the centroid
rowcent = mean(rows);
colcent = mean(cols);
%convert to polar
[theta, rho] = cart2pol(cols - colcent, rows - rowcent);
%sort in polar
[~, sortidx] = sort(theta);
%reorder x y
sort_rows = rows(sortidx);
sort_cols = cols(sortidx);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!