From XY array data in pixels to BW image
3 次查看(过去 30 天)
显示 更早的评论
Hi, I have a XY array matrix called A
, the first column are the X values (column of the image) and the second Y values (rows of the image) and I need to create a BW image in which the points of the A matrix get color white in the image.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/418373/image.png)
As an example, the A data could be:
A = randi(20,[10 2])
And the image size should be
, is that correct?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/418378/image.png)
A = randi(20,[10 2]);
idx = sub2ind([20 20],A(:,2),A(:,1));
BW = false(20,20);
BW(idx) = true;
0 个评论
采纳的回答
Ameer Hamza
2020-11-18
编辑:Ameer Hamza
2020-11-18
A little mistake in the calculation of idx
idx = sub2ind([20 20],A(:,2),A(:,1)); % Last input shoule be A(:,1)
Rest is correct.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!