フィルターのクリア

Convert XY coordinates to binary matrix

3 ビュー (過去 30 日間)
yoni verhaegen
yoni verhaegen 2017 年 3 月 23 日
コメント済み: Walter Roberson 2017 年 11 月 29 日
Hello all,
I have a 1332x2 matrix where X and Y coordinates are given of a glacier surface. When I plot the data with scatter, I just get dots at the given coordinates and it shows the glacier surface by plotting all the dots next to each other. However, I want to create a binary matrix, where 0 = no glacier and 1 = coordinate where the galcier exists. Besides, I want a line to be drawn around the glacier.
How can this be done?
Thanks already!
  2 件のコメント
Roger Stafford
Roger Stafford 2017 年 3 月 23 日
You have not given any indication of what determines the points which occur in your matrix. What is it that makes them close to one another on the glacier? Is it somehow related to the topography? It’s too bad you don’t have the third coordinate Z. One could judge by the gradient values.
Walter Roberson
Walter Roberson 2017 年 3 月 23 日
All of the x y points are on the surface of the glacier.

サインインしてコメントする。

回答 (3 件)

Walter Roberson
Walter Roberson 2017 年 3 月 23 日
Are the coordinates all positive integers? If they are then one way would be to use full() on sparse() passing in the coordinate vectors. Be careful about whether you want x to correspond to rows or columns.
If they are not positive integers, then hist2 or equivalent might be appropriate.
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 24 日
To get the line around the points consider using boundary()

サインインしてコメントする。


Image Analyst
Image Analyst 2017 年 3 月 24 日
Perhaps try scatteredInterpolant() to turn your scattered, randomly located points into a regular 2-D image with a value at every pixel.
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 24 日
This will not work. The value associated with every specified point is the constant 1. Treat those as scattered points and interpolate anywhere inside or outside the group and you will get the result 1.0 to within numeric accuracy.

サインインしてコメントする。


Anibal Carcamo
Anibal Carcamo 2017 年 11 月 29 日
I did this for a robot to convert a Distance vs Degree to a matrix of 200x400cm, it may be usefull
Code:
B=zeros(200,400);
for m=1:1:180
for l=1:1:200
for h=1:1:400
if h==tab(m,5,n)&l==tab(m,4,n)
B(l,h)=1;
end
end
end
end
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 11 月 29 日
idx = sub2ind(size(B), squeeze(tab(:,5,:)), squeeze(tab(:,4,:));
B(idx) = 1;

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by