How to get X and Y coordinates from a Sparse Matrix?

조회 수: 12 (최근 30일)
MAKESH VINEETH
MAKESH VINEETH 2020년 11월 25일
댓글: MAKESH VINEETH 2020년 11월 25일
Hey all,
I want to get X and Y coordinates of an image, so that I can generate the graph in an Excel File with those coordinates. I used below code to process an binary image:
img = imread(app.SelectImageEditField.Value);
Icomplement = imcomplement(img);
Icomplement = rgb2gray(Icomplement);
BW = imbinarize(Icomplement, 'adaptive');
out2 = bwskel(BW,'MinBranchLength',15);
BW2 = bwperim(out2,8);
Then I used the following code lines to get a digital graph:
M = sparse(BW2);
spy(M);
Now I want to grab the equivalent X and Y coordinates of this sparse matrix so that I can generate the same graph in Excel. Please suggest a solution. Thank you.

채택된 답변

KSSV
KSSV 2020년 11월 25일
편집: KSSV 2020년 11월 25일
If A is your sparse matrices. You can get positions using:
[y,x] = find(A) ; % x, y are the positons/indices of non-zeros
plot(x,y'.r')
  댓글 수: 7
KSSV
KSSV 2020년 11월 25일
:)
MAKESH VINEETH
MAKESH VINEETH 2020년 11월 25일
Thanks, it worked!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by